Import SQL file by command line in Windows 7

前端 未结 16 1468
攒了一身酷
攒了一身酷 2021-01-30 11:20

I want to import an SQL file (size > 500MB) into a database. I have wamp on my PC. Phpmyadmin does not work well with this size. I changed all parameters in php.ini (max_upload_

相关标签:
16条回答
  • 2021-01-30 11:39

    Try this it will work. Do not enter password it will ask one you execute the following cmd

    C:\xampp\mysql\bin\mysql -u xxxxx -p -h localhost your_database_name < c:\yourfile.sql
    
    0 讨论(0)
  • 2021-01-30 11:41

    mysql : < (for import) > (for export)

    in windows, you want to take backup or import the sql file, then goto cmd prompt type the address were the mysql is installed eg:C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin> after this

    C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin> mysql -u UserName -p Password DatabaseName < FileName.sql (import)

    C:\Program Files (x86)\MySQL\MySQL Server 5.6\bin> mysql -u UserName -p Password DatabaseName > FileName.sql (export)

    0 讨论(0)
  • 2021-01-30 11:44

    ----------------WARM server.

    step 1: go to cmd go to directory C:\wamp\bin\mysql\mysql5.6.17 hold Shift + right click (choose "open command window here")

    step 2: C:\wamp\bin\mysql\mysql5.6.17\bin>mysql -u root -p SellProduct < D:\file.sql

    in this case
    + Root is username database  
    + SellProduct is name database.
    + D:\file.sql is file you want to import
    

    ---------------It's work with me -------------------

    0 讨论(0)
  • 2021-01-30 11:47

    If you are using Windows PowerShell you may get the error:

    The '<' operator is reserved for future use.
    

    In that case just type the command:

    cmd
    

    To switch to the cmd shell and then retype the command and it will work.

    c:\xampp\mysql\bin\mysql -u root -p my_database < my_database_dump.sql
    

    To get back to PowerShell type:

    exit
    
    0 讨论(0)
  • 2021-01-30 11:49

    If those commands don't seems to work -- I assure you they do --, check the top of your sql dump file for the use of :

    CREATE DATABASE {mydbname}
    

    and

    USE {mydbname}
    

    The last parameter {mydbname} of the mysql command can be misleading : if CREATE DATABASE an USE are in your dump file, the import will in fact be done in this database, not in the one in the mysql command.

    The mysqldump command that will prompt CREATE DATABASE and USE is :

    mysqldump.exe -h localhost -u root --databases xxx > xxx.sql
    

    Use mysqldump without --databases to leave out CREATE DATABASE and USE :

    mysqldump.exe -h localhost -u root xxx > xxx.sql
    
    0 讨论(0)
  • 2021-01-30 11:52

    If you have wamp installed then go to command prompt , go to the path where mysql.exe exists , like for me it was : C:\wamp\bin\mysql\mysql5.0.51b\bin , then paste the sql file in the same location and then run this command in cmd :

    C:\wamp\bin\mysql\mysql5.0.51b\bin>mysql -u root -p YourDatabaseName < YourFileName.sql
    
    0 讨论(0)
提交回复
热议问题