Error while taking backup with mysqldump in mysql command line

旧时模样 提交于 2019-11-28 01:02:24

mysqldump is not a MySQL command, it is a command line utility. You must call it from your shell command line.

The problem is you are executing the command from a MySQL prompt instead of a Linux shell. Exit the mysql command line and run the command from a OS shell (remove the semicolon at the end)

In your command, you can't have a space between -p and the password. Also, mysqldump has to be run on the command line, not in a mysql shell.

Try this on your command line

mysqldump -u username -ppassword databasename > backup.sql
Rafael Barros

I didn't understood what the others was trying to say until i saw this question.

The thing is, you can't access the "mysql.exe" and put the mysqldump in it. The "mysqldump.exe" is another file, so you have to execute it from the command line of the OS passing parameters to the execution.

So, in the DOS (on Windows, of course), supose that you're in the directory: "C:\xampp\mysql\bin", then you can call the following command:

mysqldump -u root -p test > test.sql

You could also call it like this, so you can explicitly see that you're executing a file:

.\mysqldump.exe -u root -p test > test.sql

If it can be more crystal clean, you would see that line in the DOS:

c:\xampp\mysql\bin>.\mysqldump.exe -u root -p test > test.sql

Ps: in that code you would be asked to inform the password after executing. That is, indeed, the recomendation that the "mysqldump.exe" gives you if you put the password directly in the dump line.

Ps 2: if you're using the default settings of the root user (i.e. with empty password), you need to just press "Enter" when asked to inform the password.

Ps 3: the "test.sql" will be created in the same directory of the "mysqldump.exe". In this example, in: "C:\xampp\mysql\bin".

krish

Type this in your command line interface NOT in MYSQL command line:

mysqldump -u username -ppassword databasename > backup.sql

For example, if username is 'root', password is 'abcdefg', and the database name is 'mydatabase', then the syntax is:

mysqldump -u root -pabcdefg mydatabase > backup.sql

backup.sql is the name of the file in which your backup will be stored so you can have any name.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!