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
Related
I am trying to import mysql data dump to Maria DB with below command
mysql -u root -p --one-database new_db < data_dump.sql;
But I am getting below error
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MariaDB server version for the right
syntax to use near 'mysql -u root -p --one-database zapcheck <
zapcheck.sql' at line 1
I tried different combinations but nothing worked. Its not even telling what's the issue.
Please let me know the issue here or is there any other way I can import?
You can try the command below to import the file:
Note: Open the terminal where dump.sql is located
After opening the terminal:
//Skip this process if you have already created a database.
Mysql> create database newdb;
// Using the new created database
Mysql> use newdb;
// Importing the dump.sql file to newdb database
Mysql> source dump.sql
I dumped a file with gzip from remote server, this way:
mysqldump -uuser -h host_address -ppassword --quick --compress --max_allowed_packet=512M db_name table_name | gzip > my_dmp.sql.gz
and reloaded it locally, this way:
gunzip < my_dmp.sql.gz | mysql -uroot -h 127.0.0.1 --quick --compress --max_allowed_packet=512M DatabaseName
it worked before, and its still working, but now in the middle of loading it I get this error:
gunzip: (stdin): unexpected end of file
ERROR 1064 (42000) at line
276: 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 ''20' at line 1
I dont really understand, cause if there is an issue in the file how come when I go to the table locally it was created with 1.5m records out of 4m
any suggestions?
thanks!
Based on the info:
gunzip: (stdin): unexpected end of file
Your compressed file is not OK. To be sure you can try something like:
gzip -dc my_dmp.sql.gz >/dev/null
If this command return you a error this confirm it.
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.
In the Command Line I created a database with:
create database mysql;
but when i try to upload a database file with the command:
mysql -u root -p database < dbdump.sql;
i receive a syntax error and i don't understand where i'm wrong
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 database < dbdump.sql' at line 1
confirm you're running the command from a shell and not from mysql.
I recall needing to be in mysql.exe directory when running such commands
remove the spaces around <. Ie, write mysql -u root -p database<dbdump.sql
I know we can dump and restore the complete database. But, I want to know if I have multiple database or schema in one main database then what will be the syntax for that?
My database name is TEST and I tried following syntax:
### Start MySQL Backup ###
#$MYSQLDUMP -Q -u root -p "database TEST" >/usr/db/backup/"database TEST".sql;
$MYSQLDUMP -uroot "database TEST" >/backup/"database TEST"-$NOW-$(date +"%T").sql;
But, it failed with following error:
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 -uroot "database omertest" >/backup/"database omertest"-$NOW-$(date +' at line 1
If you want only schema then use this command to dump:
MYSQLDUMP -u root -p --no-data TEST >/usr/db/backup/db_backup.sql;