1

i have tried the following query but i gate with an error.

mysql> mysqldump test |mysql test1;
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 test |mysql test1' at line 1
mysql> mysqldump test |mysql test1
-> ;
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 test |mysql test1' at line 1
mysql> 
5
  • You have to do it outside of the mysql console Commented Oct 6, 2016 at 11:38
  • you have to use command prompt for that. Commented Oct 6, 2016 at 11:38
  • without console how can i do it Commented Oct 6, 2016 at 11:39
  • 1
    @adiintern not without console. You should do it in the command promp of your OS not inside of the mysql console Commented Oct 6, 2016 at 11:40
  • IIt is working fine. Commented Oct 6, 2016 at 11:44

1 Answer 1

1

You have to use these commands on command prompt.

Syntax :

mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql]

i.e.

C:\>mysqldump --all-databases > dump.sql

If you want to create dump for any specific database then you have to mention that database name in the command.

C:\>mysqldump --databases yourdb > dump.sql

To import the database you have to use following command,

C:\>mysql -p -u[user] [database] < dump.sql
Sign up to request clarification or add additional context in comments.

6 Comments

will it copy along with tables created in old database or it wont@Pirate
yeah, because you have mentionned all-databases. If you want to create only particular db then you have to give that db name only.
Error occurs: mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) when trying to connect
did you give credentials? mysqldump -u [user] database > dump.sql
try mysqldump -u[username] -p[pass] [yourdb] > dump.sql
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.