I'm unable to export my database.
I have tried several times unsuccessfully including:
mysqldump -u root -p --opt --db_2 -r backup.sql;
and
mysqldump --database --user=root --password db_2 > export_into_db.sql;
I get this error with both of them:
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 --database --user=root --password db_2 >
export_into_db.sql' at line 1
For anyone who is using mac you need to do the following steps in order to export the sql:
1.open a new terminal window
2.type this to enter the mysql if your unable to enter it PATH=$PATH:/usr/local/mysql/bin
3.mysqldump -u root -p db_2 >/Users/your_name/Desktop/sql.sql;
4.type password
Related
I want to import a sql.gz file into mySQL database, and I follow the instruction on Google. But it just failed. I really can't figure out why. So I came here to ask for help.
Here are my query commands:
zcat qmdb__v1_3__102019.sql.gz | mysql -u root -p 123456 meterial;
gunzip < F:/qmdb__v1_3__102019.sql.gz | mysql -u root -p meterial;
gunzip < qmdb__v1_3__102019.sql.gz | mysql -u root -p meterial
Three types all failed.
The error message:
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 'gunzip < qmdb__v1_3__102019.sql.gz | mysql -u root -p meterial' at line 1
enter image description here
I think my file path isn't wrong.
I try to clone my_db to my_db_clone. I followd this post and this but I get always
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
I tried thise but none worked, I get always that error :
mysqldump -u my_user -p my_db | mysql -u backup -pmy_password my_db_clone
mysqldump my_db | mysql my_db_clone;
mysqldump my_db -u my_user -pMy_passwprd > dumpdb.sql;
The mysqldump utility runs in the shell. How are you invoking it? Based on your error message, it appears that you might be trying to run it in the mysql client.
Try it in the shell instead.
I have large db so I want to export db by using putty.
Step -1 - connect to mysql
mysql -u username -p -- DBname
Then it will ask to input password. After putting password now my console is ready to execute mysql command
Step - 2 - to export db, I have tried
mysql -u username -p --dbanme > path/folder.sql
it's not working, I get error:
showing 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 mysql -u griar_riar -p --griar_riar > path/folder.sql
I have also tried:
mysql -u username -p -- dbname > /path/folder.sql
mysql -u username dbname > /path/folder.sql
I have also tried mysqldump:
mysqldump -uuser_name -ppassword -hhost_name db_name > /path/folder.sql
Please help me
Thanks
Leave out step 1 and use mysqldump directly on the shell, it is a console tool, not a MySQL command.
Use mysqldump, it's the right tool:
mysqldump -u USERNAME -p NAME_OF_DATABASE > /path/to/file/export.sql
Substitute USERNAME, NAME_OF_DATABASE and /path/to/file/export.sql to fit your needs/enviroment.
mysqldump will require you to enter your password and then export your data.
If username is pigeon and database name is airport then this will export all your data
mysqldump -u pigeon -p airport > /path/to/file/export.sql
> mysqldump -h your_host_name -P your_port_number -u your_user_name -p database_name > "/var/www/html/dbs/database_name.sql"
follow full syntax by providing hostname and port name it should works.
when I run below statement, mysql is complaining having error.
mysqldump --triggers --routines -u root -p mydb > mydb_20120924.dmp;
mysql version: 5.1.34
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 --triggers --routines -u root -p mydb > mydb_20120924.dmp' at line 1
It looks like you are trying to run the mysqldump command from inside the mysql command line interpreter.
Does the prompt for the mysqldump command say 'mysql> '? Then you are running the mysql command line interpreter. It should be used - indeed, it can only be used - for running mysql commands.
mysqldump is a separate command and must be run from the shell.
Quit mysql by typing "exit" - you will see a shell prompt. Then the mysqldump command will work.
If you have a database called "mydb" this should work. You could try using --database specifically:
mysqldump --triggers --routines -u root -p --database mydb >
mydb_20120924.dmp;
This is the command I used:
mysql> mysql -u root -p -h HOST sample < mysqldump.sql;
But I encountered an error as follows:
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 'mysql -u root -p -h HOST sample < mysqldump.sql' at line 1
Hope you can help me out?
That's the command you should give in the command line, not in MySQL itself.
Open mysql terminal or konsole and then go to the directory where mysqldump.sql file is present. try:
shell> cd /file_path/;
shell> ls -al mysqldump.sql;
It should display your file. Also you dont need to specify HOST if you are logged on to the same server.
shell> mysql -u root -p sample < mysqldump.sql;
from client you can run \. mysqldump.sql but i think first variant is preferable.