Import SQL file into mysql

I have a database called nitm . I haven't created any tables there. But I have a SQL file which contains all the necessary data for the database. The file is nitm.sql which is in C: drive . This file has size of about 103 MB. I am using wamp server.

I have used the following syntax in MySQL console to import the file:

mysql>c:/nitm.sql;

But this didn't work.


From the mysql console:

mysql> use DATABASE_NAME;

mysql> source path/to/file.sql;


make sure there is no slash before path if you are referring to a relative path... it took me a while to realize that! lol


Finally, i solved the problem. I placed the `nitm.sql` file in `bin` file of the `mysql` folder and used the following syntax.

C:wampbinmysqlmysql5.0.51bbin>mysql -u root nitm < nitm.sql

And this worked.


If you are using wamp you can try this. Just type use your_Database_name first.

  • Click your wamp server icon then look for MYSQL > MSQL Console then run it.

  • If you dont have password, just hit enter and type :

    mysql> use database_name;
    mysql> source location_of_your_file;
    

    If you have password, you will promt to enter a password. Enter you password first then type:

    mysql> use database_name;
    mysql> source location_of_your_file;
    
  • location_of_your_file should look like C:mydb.sql

    so the commend is mysql>source C:mydb.sql;

    This kind of importing sql dump is very helpful for BIG SQL FILE.

    I copied my file mydb.sq to directory C: .It should be capital C: in order to run

    and that's it.

    链接地址: http://www.djcxy.com/p/30352.html

    上一篇: 导入大型sql文件时,MySQL服务器已经消失

    下一篇: 将SQL文件导入到mysql中