Import SQL file by command line in Windows 7

前端 未结 16 1466
攒了一身酷
攒了一身酷 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:32

    If you are running WampServer on your local machine, import means restoring the dump file that you have (in sql format)

    Here are the steps

    1. Go to command line by going to Start -> Run and typing in cmd.
    2. Change the directory to Mysql bin directory. It will be like

      c:\wamp\bin\mysql\mysql5.7.14\bin

    3. It would be better to keep the dump file in the above directory( we can delete, after restoration)

    4. Hope you have created the database (either through phpMyadmin or using command line)

    5. Then type the command mysql.exe -u root -p databasename < filename.sql

    Please note the difference, it is 'mysql.exe' not 'mysql'

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

    First open Your cmd pannel And enter mysql -u root -p (And Hit Enter) After cmd ask's for mysql password (if you have mysql password so enter now and hit enter again) now type source mysqldata.sql(Hit Enter) Your database will import without any error

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

    To import database from dump file (in this case called filename.sql)

        use: mysql -u username -p password database_name < filename.sql 
    

    you are on Windows you will need to open CMD and go to directory where mysql.exe is installed. you are using WAMP server then this is usually located in: C:\wamp\bin\mysql\mysql5.5.8\bin (*note the version of mysql might be different)

    So you will: cd C:\wamp\bin\mysql\mysql5.5.8\bin

    and then execute one of the above commands. Final command like this

        C:\wamp\bin\mysql\mysql5.5.8\bin>mysql -u rootss -p pwdroot testdatabasename < D:\test\Projects\test_demo_db.sql
    
    0 讨论(0)
  • 2021-01-30 11:36

    Try like this:

    I think you need to use the full path at the command line, something like this, perhaps:

    C:\xampp\mysql\bin\mysql -u {username} -p {databasename} < file_name.sql
    

    Refer this link also:

    http://www.ryantetek.com/2011/09/importing-large-sql-files-through-command-line-when-using-phpmyadminxampp/

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

    I use mysql -u root -ppassword databasename < filename.sql in batch process. For an individual file, I like to use source more because it shows the progress and any errors like

    Query OK, 6717 rows affected (0.18 sec)
    Records: 6717  Duplicates: 0  Warnings: 0
    
    1. Log in to MySQL using mysql -u root -ppassword
    2. In MySQL, change the database you want to import in: mysql>use databasename;

      • This is very important otherwise it will import to the default database
    3. Import the SQL file using source command: mysql>source path\to\the\file\filename.sql;

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

    To import SQL file what works for me

    For Wamp-Server

    1. Find mysql in wamp. In my computer it's location is "C:\wamp64\bin\mysql\mysql5.7.21\bin"

    Open cmd and once you get inside bin you have to write " mysql -uroot -p database_name < filename.sql"

    remember to put sql file under bin.

    in nutshell you have to do this:-

    C:\wamp64\bin\mysql\mysql5.7.21\bin>mysql -uroot -p database_name < filename.sql

    After this, it will ask for the password, mine password was nothing(BLANK).

    hope it helps someone.

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