Issue to clone mysql DB - mysql

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.

Related

Can't import file dumped by mysqldump

I created a dump from a database that we have on a kube pod as follows:
kubectl exec mysql-0 -n pod-name -- mysqldump -u root -ppass dbname > ~/Desktop/dump.sql
I then try to import this database into my local db by:
mysql ebdb --force -uroot -proot < ~/Desktop/dump.sql
But I keep getting errors as:
ERROR 1064 (42000) at line 4550: 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 ''---\nid: 195\nrestaurant_id: 4330\napi_key: sk_live_wVi93Gt11111puIE\nm' at line 1
I repeated the dumping and importing multiple times with similar errors: syntax problems.
I thought maybe the error has to do with encoding, so I dumped using
kubectl exec mysql-0 -n pod-name -- mysqldump -u root -ppass --default-character-set=utf8 ebdb > ~/Desktop/dump.sql
but still same error.
Any ideas about what might be going wrong here?
p.s: Of course I'm changing the name of the pod and pass here as well as some of the chars in the api key for obvious reasons. Otherwise things are left as is

How to import sql,gz file into my databases

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.

Unable to export entire db

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

General server configuration WSO2 EMM

I'm almost through and I got stuck at the General Server Configuration from step 6. As in when I try the 7th step, I receive below error;
mysql> mysql -u admin -p -D EMM_DB <
/usr/local/bin/wso2emm/dbscripts/emm_mysql.sql; 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 admin -p -D EMM_DB <
/usr/local/bin/wso2emm/dbscripts/emm_mysql.sql' at line 1
I assume that the command I'm issuing is incorrect and if someone could clear out the issue.
Database name field, should be joined with the -D and also I would suggest to use UTF8 parameter
mysql> mysql -u admin -p -DEMM_DB --default_character_set=utf8 < /usr/local/bin/wso2emm/dbscripts/emm_mysql.sql;

How to backup and restore in MySQL 5.2?

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.