user732027
user732027

Reputation: 99

mysql dump error

I'm having some difficulty with mysqldump. I locked my tables and ran the following command:

mysqldump -u user -p password databasename using my actual password and database name.

When I run this from mysql I get a 1064 error that says there is an issue with my syntax. I've also tried running the command from terminal (outside of mysql) and receive a 'command not found' error message. I'm not entirely sure how I should be doing this (the explanations I've found so far have been vague).

Thanks for the help.

Upvotes: 2

Views: 2383

Answers (3)

Mihai Iorga
Mihai Iorga

Reputation: 39724

the correct syntax is

mysqldump -u [username] -p[password] [databasename] > [backupfile.sql]

you should add the > backupfile.sql

the other error is believe your system doesn't recognize the mysqldump path and you should go directly to bin folder from mysql installation.

Upvotes: 0

Devart
Devart

Reputation: 122032

  1. The mysqldump is a program, it cannot be executed from the mysql console. Run it from the shell.

  2. Have a look at the syntax reference.

    --user=user_name, -u user_name

    --password[=password], -p[password]

As you see there is no space between -p and password. So, your command line should be like this:

>shell mysqldump -u <user_name> -p<user_password> ...

or

>shell mysqldump --user=<user_name> --password=<user_password> ...

Upvotes: 3

Naveed
Naveed

Reputation: 42143

You are missing the target backup file name:

# [mysql dir]/bin/mysqldump -u username -p password --databases databasename > /tmp/databasename.sql

Upvotes: 0

Related Questions