从命令行备份 mysql 数据库
我正在尝试备份我的数据库并不断收到错误:
错误 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 '$ mysqldump -u root -p chandlers > 附近使用的正确语法。 backup_db.sql' 在第 1 行
我使用以下命令来启动备份:
$ mysqldump -h localhost -u root -p chandlers > backup_db.sql
edit>>>> 这就是我连接到数据库的方式,这是我设置的打开命令行的快捷方式:
C:\server2go\server2go\server\mysql\bin\mysql.exe -h localhost -P 7188 -u root
这工作正常并且连接,我尝试创建另一个像这样的>>
C:\server2go\server2go\server\mysql\bin\mysqldump.exe $ mysqldump -h localhost -P 7188 -u root -pchandlers > backup_db.sql
但我现在收到访问被拒绝错误。
I am trying to backup my database and keep getting error :
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$ mysqldump -u root -p chandlers > backup_db.sql' at line 1
I am using the following command to launch the backup :
$ mysqldump -h localhost -u root -p chandlers > backup_db.sql
edit>>>>
This is how I connect to the db, this is a shortcut I have setup to open a command line :
C:\server2go\server2go\server\mysql\bin\mysql.exe -h localhost -P 7188 -u root
This works fine and connects, I have tried creating another like this >>
C:\server2go\server2go\server\mysql\bin\mysqldump.exe $ mysqldump -h localhost -P 7188 -u root -pchandlers > backup_db.sql
but I am getting an access denied error now.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用mysqldump来备份mysql数据库。
下面是在命令行中备份 mysql 数据库的脚本示例:-
如果您的 mysql 数据库非常大,您可能需要压缩 sql 文件。
只需使用下面的 mysql 备份命令并将输出通过管道传输到 gzip,
然后你将得到 gzip 文件的输出。
如果您想提取 .gz 文件,请使用以下命令:-
you can use mysqldump to backup mysql database.
Below is the script example to backup mysql database in command line:-
If your mysql database is very big, you might want to compress your sql file.
Just use the mysql backup command below and pipe the output to gzip,
then you will get the output as gzip file.
If you want to extract the .gz file, use the command below:-
您似乎是从 mySQL 中调用 mysqldump ,这是不正确的 - 它是一个单独的可执行文件。
相反,从命令行调用它。
You seem to be calling
mysqldump
from within mySQL, which is incorrect - it's a separate executable.Call it from the command line instead.
我认为应该是 $ mysqldump -h localhost -u root -pchandlers > backup_db.sql。否则对我来说似乎很好。
I think it should be
$ mysqldump -h localhost -u root -pchandlers > backup_db.sql
. Otherwise it seems fine to me.