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
Related
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
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 have a MySQL database which I want to duplicate using the Ubuntu Linux CLI without first having to download a MySQL file. I tried the following command:
mysql -uroot -e'mysqldump -uroot db_old | mysql -uroot backup db_new;'
But got this error:
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use.
What am I doing wrong? What I'm looking for is for db_new to be created containing the same data as db_old (in other words, copy db_old and name the new database db_new, all in one command without needing to export the data to a file).
First, create the new database
mysql -uroot -pyourpasswd -e "Create database db_new;"
Then run the following (you don't need to execute "-e")
mysqldump -uroot -pyourpasswd -n db_old | mysql -uroot -pyourpasswd db_new;
From the man page:
mysqldump is also very useful for populating databases by copying data
from one MySQL server to another:
shell> mysqldump --opt db_name | mysql --host=remote_host -C db_name
The "-n" option is short for "--no-create-db"
If you don't need a password for your root connection (not recommended), then remove the "-pyourpasswd" from all statements
i am trying to import sql file through putty
below are my details of DB
dbname - test,
password - test123,
username -utest,
i tried the below code
mysql -u utest -p test123 test< /home/path/public_html/file.sql
when i run this command i saw a 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 'mysql -u utest -p test123 test < file' at line 1
please suggest how to import sql file
Thank Sanjib
try this
mysql -utest -ptest123 test < /home/path/public_html/file.sql
and make sure that you run this command from your console not in mysql
if you are in mysql prompt than it would be somehting like this
mysql> use test;
mysql> source /home/path/public_html/file.sql;
OR
mysql>SET autocommit=0; source /home/path/public_html/file.sql; COMMIT;
You should run this command in your console, outside of the mysql tool.
I am unable to create mysql database dump. I have tried all the commands in the below question
https://stackoverflow.com/questions/24858436/unable-to-create-mysql-dump-in-mysql-server-5-6-19
But every time I get similar error which asks me to check manual
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
dump -u root -pmysqlmysql hospital_management -r "c:\hosp.sql"' at line 1
I am trying these commands in Mysql command line and NOT on Windows command prompt. Also I am trying these commands before entering any database in mysql.
mysql> mysqldump -u root -pmysqlmysql hospital_management > hosp.sql
This was the first command I tried, which did not work
mysqldump is an executable, you should not run it in the MySQL command line.
Try the command
mysqldump -uroot -pmysqlmysql hospital_management > "C:\hosp.sql"
By reading the documentation, I assume that when using -r, the file must already exist.