使用 mysqldump.exe 将 mysql 数据库从本地主机复制到远程服务器
我想将 mysql 数据库从本地计算机复制到远程服务器。
我正在尝试使用 mysql dump 命令。互联网上的所有示例都建议执行类似的操作。
初始 mysql>
只是我登录后得到的提示。
mysql> mysqldump -u user -p pass myDBName | NewDBName.out;
但是当我这样做时,我得到You have an error in your SQL语法;检查对应的手册...以在'mysqldump -u user -p pass myDBName | 附近使用NewDBName.out'
由于我已经登录,是否需要使用 -u 和 -p?不这样做会给我同样的错误。你能看出哪里出了问题吗?
I want to copy a mysql database from my local computer to a remote server.
I am trying to use the mysql dump command. All the examples on the internet suggest doing something like
The initial mysql>
is just the prompt I get after logging in.
mysql> mysqldump -u user -p pass myDBName | NewDBName.out;
But when I do this I get You have an error in your SQL syntax; check the manual that corresponds ... to use near 'mysqldump -u user -p pass myDBName | NewDBName.out'
Since I have already logged in do I need to use -u and -p? Not doing so gives me the same error. Can you see what is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了 Alexandre 所说的之外,您可能不想通过管道 (|) 输出到 NewDBName.out,而是将其重定向到那里 (>)。
因此,从 Windows/Unix 命令行:
请注意,如果某些列中有较大的二进制字段(例如 BLOBS),您可能需要设置一个附加选项(我认为它是 --hex-blob,但可能还有另一个选项)也)。如果这适用于您,请添加评论,我将研究该设置。
In addition to what Alexandre said, you probably don't want to pipe (|) output to NewDBName.out, but rather redirect it there (>).
So from the Windows/Unix command line:
Note that if you have large binary fields (e.g. BLOBS) in some columns you may need to set an additional option (I think it was --hex-blob, but there might have been another option too). If that applies to you, add a comment and I'll research the setting.
mysqldump
不是您在mysql
会话中执行的 SQL 语句,而是应该从操作系统 shell 启动的不同二进制文件。有几种使用它的方法。其中之一是将 mysqldump 的输出通过管道传输到另一个 MySQL 实例:
mysqldump
is not an SQL statement that you execute inside amysql
session but a distinct binary that should be started from your OS shell.The are a few ways to use this. One of them is to pipe the output of
mysqldump
to another MySQL instance:我最近不得不转储大量数据。我在一个 200Mb 的数据库中发现,许多表中有 10,000 多条记录,如下所示。我使用 linux 'time' 命令来获取实际时间。
12 分钟使用:
mysqldump -u 用户 -p pass myDBName > db-backups.sql
7分钟克隆数据库:
mysqldump -u 用户 -p 传递 myDBName | mysql -u user -p pass cloneDBName
在不到一秒的时间内:
mysqlhotcopy -u user -p pass myDBName cloneDBName
最后一个让我大吃一惊,但是您必须在数据库服务器所在的本地登录。我个人认为这比远程转储要快得多,您可以压缩 .sql 文件并手动传输它。
I have had to dump large sets of data recently. From what I have found on a 200Mb database with 10,000+ records in many of the tables is the following. I used the linux 'time' command to get actual time.
12 minutes using:
mysqldump -u user -p pass myDBName > db-backups.sql
7 minutes to clone the database:
mysqldump -u user -p pass myDBName | mysql -u user -p pass cloneDBName
And in less than a second:
mysqlhotcopy -u user -p pass myDBName cloneDBName
The last one blew my mind, but you have to be logged in locally where the database server resides. Personally I think this is much faster than remotely doing a dump, the you can compress the .sql file and transfer it manually.