views:

35

answers:

2

mysql gives me the syntax error with the following line... i dont know what is wrong with this...

mysqldump -u root -p root mydatabase > dumpfile.sql

i am using windows vista...

plz help here.. thnx..

+3  A: 

The -p part is the problem. From the manual:

The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, you are prompted for one.

Try

mysqldump -u root -proot mydatabase > dumpfile.sql

But in the future, please ask a proper question including any error messages you get (you certainly got one in this case) so people don't have to guess.

Pekka
still i am having the syntax error... :(
Jamal Abdul Nasir
*What* syntax error?
Pekka
I usually also omit the space between -u and username to get password and user consistent. But the error message should be pretty easy - cannot connect user root without password or something like that.
extraneon
ERROR 1064 <42000>: You have an error in your sql syntax...
Jamal Abdul Nasir
@Jamal and at which point does that error come up? Surely not when calling `mysqldump`?
Pekka
well it says that the error occurred near (prints whole query)...
Jamal Abdul Nasir
i am running this from mysql command prompt on windows vista... mysql version is 5.1.45
Jamal Abdul Nasir
@Jamal no no no, mysqldump is a separate program. You run it from the normal Windows command line.
Pekka
+2  A: 

Make sure that you are running this from the normal command line and not within the mysql command line. So like this:

C:\[path to mysqldump app] > mysqldump -u root -p root mydatabase > dumpfile.sql

not

mysql > mysqldump -u root -p root mydatabase > dumpfile.sql
spinon
This seems to be the solution.
Pekka
Right. mysqldump is a separate program, not a command to use in a mysql client.
grossvogel
hmmm... when i run the following command:C:\[path to mysqldump app] > mysqldump -u root -p root mydatabase > dumpfile.sqlthen i was asked for the password when i enter the "root" as a password it gave me an error:mysqldump: Got error: 1045: Access denied for user 'root@localhost' (using password yes) when trying to connect.but when i remove the password from the command and ran it i was asked for the password which i entered "root"; was a successful run...C:\[path to mysqldump app] > mysqldump -u root -p mydatabase > dumpfile.sqlthnx aloadz guyz... really appreciate it...
Jamal Abdul Nasir
First off check @Pekka answer below as to why it asked you for the password again even though you specified. You have a space between -p and the password. Remove that and it will fix the problem of it asking you again. As to your other question not sure exactly why that would be.
spinon