I created a database using Mysql Workbench. Now I want to export this database to my home PC.
我使用Mysql Workbench创建了一个数据库。现在我想把这个数据库导出到我的家庭电脑。
How can I do this if the 2 PCs have no network connection?
如果这两台pc没有网络连接,我怎么做呢?
3 个解决方案
#1
1
I use mysqldump to export the database. You can use something like
我使用mysqldump来导出数据库。你可以用类似的东西
mysqldump -u [username] -p [database name] > backup.sql
to store it in a file. After that you can import into another database via
将它存储在一个文件中。之后,您可以通过以下方式导入另一个数据库。
mysql -u [username] -p [database name] < backup.sql
#2
1
As edit was rejected posting it as an answer; hope it will be helpful. Followed to the queries give by "Marc Hauptmann" -
如编辑被拒绝,将其作为答案发布;希望会有帮助。接下来是“Marc Hauptmann”的问题
Few quick-tips for generic issues that can be faced while performing DB dump and restore:-
对于执行DB转储和恢复时可能遇到的一般性问题,很少有快速提示:-
- As correctly mentioned above by "Marc" it is always advised not to provide db password in command line export [if you do so, it can be easily sniffed in history or reverse-search]
- 正如上面“Marc”所正确提到的,建议在命令行导出中不要提供db密码(如果您这样做,可以很容易地在历史或反向搜索中进行嗅探)
- If you are transferring large dump file it is advised to compress it before transferring. [it should be uncompressed before restore]
- 如果您正在传输大的转储文件,建议在传输之前压缩它。[恢复前应先解压]
- While exporting if you want to export data with 'new database name' it can also be done. [It will require new Db to be created before using it in import]
- 如果您希望导出带有“新数据库名称”的数据,则可以进行导出。[在导入前需要创建新的Db]
- Also if we are exporting data from production servers to make sure it doesn't impact performance, export from other servers with below additional option "-h [hostname]"
- 另外,如果我们要从生产服务器导出数据以确保其不会影响性能,那么可以从其他服务器导出,并在下面添加“-h [hostname]”选项
mysqldump -h [hostname] -u [username] -p [database name] > backup.sql
mysqldump -h[主机名]-u[用户名]-p[数据库名称]>备份。sql。
#3
0
Using gzip is pretty painless and really shrinks these files.
使用gzip是非常简单的,并且会缩小这些文件。
mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]
mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]
gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]
(backupfile.sql gunzip <。mysql -u [uname] -p[pass] [dbname]
But man, it is 2014 - this stuff is also easy to do via a secure shell connection.
但天啊,现在是2014年了——通过安全的shell连接,这也很容易做到。
#1
1
I use mysqldump to export the database. You can use something like
我使用mysqldump来导出数据库。你可以用类似的东西
mysqldump -u [username] -p [database name] > backup.sql
to store it in a file. After that you can import into another database via
将它存储在一个文件中。之后,您可以通过以下方式导入另一个数据库。
mysql -u [username] -p [database name] < backup.sql
#2
1
As edit was rejected posting it as an answer; hope it will be helpful. Followed to the queries give by "Marc Hauptmann" -
如编辑被拒绝,将其作为答案发布;希望会有帮助。接下来是“Marc Hauptmann”的问题
Few quick-tips for generic issues that can be faced while performing DB dump and restore:-
对于执行DB转储和恢复时可能遇到的一般性问题,很少有快速提示:-
- As correctly mentioned above by "Marc" it is always advised not to provide db password in command line export [if you do so, it can be easily sniffed in history or reverse-search]
- 正如上面“Marc”所正确提到的,建议在命令行导出中不要提供db密码(如果您这样做,可以很容易地在历史或反向搜索中进行嗅探)
- If you are transferring large dump file it is advised to compress it before transferring. [it should be uncompressed before restore]
- 如果您正在传输大的转储文件,建议在传输之前压缩它。[恢复前应先解压]
- While exporting if you want to export data with 'new database name' it can also be done. [It will require new Db to be created before using it in import]
- 如果您希望导出带有“新数据库名称”的数据,则可以进行导出。[在导入前需要创建新的Db]
- Also if we are exporting data from production servers to make sure it doesn't impact performance, export from other servers with below additional option "-h [hostname]"
- 另外,如果我们要从生产服务器导出数据以确保其不会影响性能,那么可以从其他服务器导出,并在下面添加“-h [hostname]”选项
mysqldump -h [hostname] -u [username] -p [database name] > backup.sql
mysqldump -h[主机名]-u[用户名]-p[数据库名称]>备份。sql。
#3
0
Using gzip is pretty painless and really shrinks these files.
使用gzip是非常简单的,并且会缩小这些文件。
mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]
mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]
gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]
(backupfile.sql gunzip <。mysql -u [uname] -p[pass] [dbname]
But man, it is 2014 - this stuff is also easy to do via a secure shell connection.
但天啊,现在是2014年了——通过安全的shell连接,这也很容易做到。