<i id='jVbmA'><tr id='jVbmA'><dt id='jVbmA'><q id='jVbmA'><span id='jVbmA'><b id='jVbmA'><form id='jVbmA'><ins id='jVbmA'></ins><ul id='jVbmA'></ul><sub id='jVbmA'></sub></form><legend id='jVbmA'></legend><bdo id='jVbmA'><pre id='jVbmA'><center id='jVbmA'></center></pre></bdo></b><th id='jVbmA'></th></span></q></dt></tr></i><div id='jVbmA'><tfoot id='jVbmA'></tfoot><dl id='jVbmA'><fieldset id='jVbmA'></fieldset></dl></div>
<legend id='jVbmA'><style id='jVbmA'><dir id='jVbmA'><q id='jVbmA'></q></dir></style></legend>

      <bdo id='jVbmA'></bdo><ul id='jVbmA'></ul>

        <small id='jVbmA'></small><noframes id='jVbmA'>

        <tfoot id='jVbmA'></tfoot>
      1. MySQL:在同一个 MySql 实例上克隆一个 MySQL 数据库

        MySQL: Cloning a MySQL database on the same MySql instance(MySQL:在同一个 MySql 实例上克隆一个 MySQL 数据库)

          1. <i id='9333K'><tr id='9333K'><dt id='9333K'><q id='9333K'><span id='9333K'><b id='9333K'><form id='9333K'><ins id='9333K'></ins><ul id='9333K'></ul><sub id='9333K'></sub></form><legend id='9333K'></legend><bdo id='9333K'><pre id='9333K'><center id='9333K'></center></pre></bdo></b><th id='9333K'></th></span></q></dt></tr></i><div id='9333K'><tfoot id='9333K'></tfoot><dl id='9333K'><fieldset id='9333K'></fieldset></dl></div>
              <tbody id='9333K'></tbody>
              <legend id='9333K'><style id='9333K'><dir id='9333K'><q id='9333K'></q></dir></style></legend>

                  <bdo id='9333K'></bdo><ul id='9333K'></ul>
                • <small id='9333K'></small><noframes id='9333K'>

                  <tfoot id='9333K'></tfoot>

                  本文介绍了MySQL:在同一个 MySql 实例上克隆一个 MySQL 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想编写一个脚本,将我当前的数据库 sitedb1 复制到同一个 mysql 数据库实例上的 sitedb2.我知道我可以将 sitedb1 转储到 sql 脚本:

                  mysqldump -u root -p sitedb1 >~/db_name.sql

                  然后将其导入sitedb2.有没有更简单的方法,无需将第一个数据库转储到 sql 文件中?

                  解决方案

                  正如手册中所说的 复制数据库 您可以将转储直接通过管道传输到 mysql 客户端:

                  mysqldump db_name |mysql new_db_name

                  如果您使用的是 MyISAM,您可以复制文件,但我不建议这样做.有点不靠谱.

                  整合了各种其他好的答案

                  mysqldumpmysql 命令都接受用于设置连接详细信息(以及更多)的选项,例如:

                  mysqldump -u <用户名>--password=<原始数据库>|mysql -u <用户名>-p <新数据库>

                  此外,如果新数据库还不存在,您必须事先创建它(例如使用 echo "create database new_db_name" | mysql -u <dbuser> -p).

                  I would like to write a script which copies my current database sitedb1 to sitedb2 on the same mysql database instance. I know I can dump the sitedb1 to a sql script:

                  mysqldump -u root -p sitedb1 >~/db_name.sql
                  

                  and then import it to sitedb2. Is there an easier way, without dumping the first database to a sql file?

                  解决方案

                  As the manual says in Copying Databases you can pipe the dump directly into the mysql client:

                  mysqldump db_name | mysql new_db_name
                  

                  If you're using MyISAM you could copy the files, but I wouldn't recommend it. It's a bit dodgy.

                  Integrated from various good other answers

                  Both mysqldump and mysql commands accept options for setting connection details (and much more), like:

                  mysqldump -u <user name> --password=<pwd> <original db> | mysql -u <user name> -p <new db>
                  

                  Also, if the new database is not existing yet, you have to create it beforehand (e.g. with echo "create database new_db_name" | mysql -u <dbuser> -p).

                  这篇关于MySQL:在同一个 MySql 实例上克隆一个 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)

                  <i id='g7AYA'><tr id='g7AYA'><dt id='g7AYA'><q id='g7AYA'><span id='g7AYA'><b id='g7AYA'><form id='g7AYA'><ins id='g7AYA'></ins><ul id='g7AYA'></ul><sub id='g7AYA'></sub></form><legend id='g7AYA'></legend><bdo id='g7AYA'><pre id='g7AYA'><center id='g7AYA'></center></pre></bdo></b><th id='g7AYA'></th></span></q></dt></tr></i><div id='g7AYA'><tfoot id='g7AYA'></tfoot><dl id='g7AYA'><fieldset id='g7AYA'></fieldset></dl></div>

                        <small id='g7AYA'></small><noframes id='g7AYA'>

                          <tbody id='g7AYA'></tbody>
                            <bdo id='g7AYA'></bdo><ul id='g7AYA'></ul>
                          • <tfoot id='g7AYA'></tfoot>
                            <legend id='g7AYA'><style id='g7AYA'><dir id='g7AYA'><q id='g7AYA'></q></dir></style></legend>