Import SQL file into mysql

前端 未结 18 1359
盖世英雄少女心
盖世英雄少女心 2020-11-28 00:16

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

相关标签:
18条回答
  • 2020-11-28 01:05

    from the command line (cmd.exe, not from within mysql shell) try something like:

    type c:/nite.sql | mysql -uuser -ppassword dbname
    
    0 讨论(0)
  • 2020-11-28 01:09

    Export Particular DataBases

     djimi:> mysqldump --user=root --host=localhost --port=3306 --password=test -B CCR KIT >ccr_kit_local.sql
    

    this will export CCR and KIT databases...

    Import All Exported DB to Particular Mysql Instance (You have to be where your dump file is)

    djimi:> mysql --user=root --host=localhost --port=3306 --password=test < ccr_kit_local.sql
    
    0 讨论(0)
  • 2020-11-28 01:10

    For those of you struggling with getting this done trying every possible answer you can find on SO. Here's what worked for me on a VPS running Windows 2012 R2 :

    1. Place your sql file wherever the bin is for me it is located at C:\Program Files\MySQL\MySQL Server 8.0\bin

    2. Open windows command prompt (cmd)

    3. Run C:\Program Files\MySQL\MySQL Server 8.0\bin > mysql -u [username] -p
    4. Enter your password
    5. Run command use [database_name];
    6. Import your file with command source C://Program Files//MySQL//MySQL Server 8.0//bin//mydatabasename.sql

    It did it for me as everything else had failed. It might help you too.

    0 讨论(0)
  • 2020-11-28 01:11

    If you are using xampp

    C:\xampp\mysql\bin\mysql -uroot -p nitm < nitm.sql
    
    0 讨论(0)
  • 2020-11-28 01:11

    I have installed my wamp server in D: drive so u have to go to the following path from ur command line->(and if u have installed ur wamp in c: drive then just replace the d: wtih c: here)

    D:\>cd wamp
    D:\wamp>cd bin
    D:\wamp\bin>cd mysql
    D:\wamp\bin\mysql>cd mysql5.5.8 (whatever ur verserion will be displayed here use keyboard Tab button)
    D:\wamp\bin\mysql\mysql5.5.8>cd bin
    D:\wamp\bin\mysql\mysql5.5.8\bin>mysql -u root -p password db_name < "d:\backupfile.sql"
    

    here root is user of my phpmyadmin password is the password for phpmyadmin so if u haven't set any password for root just nothing type at that place, db_name is the database (for which database u r taking the backup) ,backupfile.sql is the file from which u want ur backup of ur database and u can also change the backup file location(d:\backupfile.sql) from to any other place on your computer

    0 讨论(0)
  • 2020-11-28 01:13

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

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

    2. 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.

    0 讨论(0)
提交回复
热议问题