How to import a .sql file

爷,独闯天下 提交于 2020-01-02 05:14:05

问题


I'm running MySQL on Ubuntu 10.4 LTS and unfortunately I've been experiencing serious problems when it comes to importing a sql file.

What I actually do:

1) I move to the directory containing the sql file which is called: bk.sql

2) Then I type :

mysql -u root -p (and then I enter the root password and everything goes smoothly)

3) I use this command to do the import operation (assuming that password =123m Database name = Mydb sql file = bk.sql)

mysql -u root -p 123m Mydb < bk.sql;

What I get is :

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 123m Mydb < bk.sql' at line 1

Is the import procedure correct?


回答1:


It looks like you are running the mysql import command from the mysql prompt which is not right.

You don't need to do step 2. Just do steps 1 and 3.




回答2:


Do this, and you will have it.

mysql -u root -ptoor -h localhost database_in_mysql < local_sql_file.sql
mysql> show databases;

mysql> use meow;
mysql> select * from customers_meow;

and you'll see all the tables, bingo ! ch33rs.




回答3:


First enter this.. in cmd or terminal...

mysql -u root -p Mydb < bk.sql

Then it ask password

Password : 123m

Now wait .. i will take several time .. thats all...



来源:https://stackoverflow.com/questions/7316507/how-to-import-a-sql-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!