无法使mysqldump工作(Can't get mysqldump to work)

编程入门 行业动态 更新时间:2024-10-28 13:13:57
无法使mysqldump工作(Can't get mysqldump to work)

我正在尝试制作数据库的副本,以便我可以将其作为文件发送给其他人,以便他们可以使用该副本。 我正在尝试使用mysqldump,我正在查看文档,但我无法让它工作。

我现在只是想复制一个名为test2的数据库。 在MySQL命令行客户端我正在做mysqldump test2 > dump.sql; 我收到错误消息: You have an error in your SQL suntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqldump test2 > dump.sql' at line 1. You have an error in your SQL suntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqldump test2 > dump.sql' at line 1.

继续,告诉我,我很蠢。 我需要一些帮助。

I'm trying to make a copy of a database so I can send it as to someone else as a file so they can use the copy. I'm trying to use mysqldump for this, I'm looking at the documentation but I can't get it to work.

I'm just trying to copy a database called test2 right now. In the MySQL command line client I'm doing mysqldump test2 > dump.sql; I'm getting the error message: You have an error in your SQL suntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysqldump test2 > dump.sql' at line 1.

Go on, tell me I'm stupid. I just need some help, please.

最满意答案

我使用Unix命令行中的以下内容来备份和重新创建数据库:

备份数据库:

一般:

$ mysqldump -u<username> -p<password> -h<hostname> <database> | gzip - > <database>.dump.<datestamp>.gz

例:

$ mysqldump -usandro -psecrete -hlocalhost books | gzip - > books.dump.2015-06-20.gz

从备份加载数据库

$ gunzip -c books.dump.2015-06-20.gz | mysql -usandro2 -psecrete2 -host2

gzipgunzip用于压缩和解压缩备份文件以节省空间。 --c用于stdinstdout 。 通常gzipgunzip处理文件。

如果数据库不存在,则加载示例将创建数据库。 如果数据库已存在,则加载将使用新表替换所有现有表。

I use the following from the Unix command line to back up and recreated databases:

Back up a database:

General:

$ mysqldump -u<username> -p<password> -h<hostname> <database> | gzip - > <database>.dump.<datestamp>.gz

Example:

$ mysqldump -usandro -psecrete -hlocalhost books | gzip - > books.dump.2015-06-20.gz

Load a database from backup

$ gunzip -c books.dump.2015-06-20.gz | mysql -usandro2 -psecrete2 -host2

gzip and gunzip are used to compress and uncompress the backup file to save space. The - and the -c are used for stdin and stdout. Normally gzip and gunzip work on files.

The loading example will create the database should it not exist. If the database already exists, the loading will replace all existing tables with new ones.

更多推荐

本文发布于:2023-08-07 02:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1458298.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:工作   mysqldump   work

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!