Importing larger sql files into MySQL

前端 未结 14 2150
感情败类
感情败类 2020-12-12 10:45

I have a 400MB large sql backup file. I\'m trying to import that file into MySQL database using WAMP->import, but the import was unsuccessful due to many reasons such as upl

相关标签:
14条回答
  • 2020-12-12 11:07

    Use this from mysql command window:

    mysql> use db_name;
    mysql> source backup-file.sql;
    
    0 讨论(0)
  • 2020-12-12 11:09

    3 things you have to do, if you are doing it locally:

    in php.ini or php.cfg of your php installation

    post_max_size=500M
    
    upload_max_filesize=500M
    
    memory_limit=900M
    

    or set other values. Restart Apache.

    OR

    Use php big dump tool its best ever i have seen. its free and opensource

    http://www.ozerov.de/bigdump/

    0 讨论(0)
  • 2020-12-12 11:11

    I really like the BigDump to do it. It's a very simple PHP file that you edit and send with your huge file through SSH or FTP. Run and wait! It's very easy to configure character encoding, comes UTF-8 by default.

    0 讨论(0)
  • 2020-12-12 11:11

    Had a similar problem, but in Windows. I was trying to figure out how to open a large MySql sql file in Windows, and these are the steps I had to take:

    • Go to the download website (http://dev.mysql.com/downloads/).
    • Download the MySQL Community Server and install it (select the developer or full install, so it will install client and server tools).
    • Open MySql Command Line Client from the Start menu.
    • Enter your password used in install.
    • In the prompt, mysql>, enter:

      CREATE DATABASE database_name;

      USE database_name;

      SOURCE myfile.sql

    That should import your large file.

    0 讨论(0)
  • 2020-12-12 11:12

    Since you state (in a clarification comment to another person's answer) that you are using MySQL Workbench, you could try using the "sql script" option there. This will avoid the need to use the commandline (although I agree with the other answer that it's good to climb up on that horse and learn to ride).

    1. In MySQL Workbench, go to File menu, then select "open script". This is probably going to take a long time and might even crash the app since it's not made to open things that are as big as what you describe.

    2. The better way is to use the commandline. Make sure you have MySQL client installed on your machine. This means the actual MySQL (not Workbench GUI or PhpMyAdmin or anything like that). Here is a link describing the command-line tool. Once you have that downloaded and installed, open a terminal window on your machine, and you have two choices for slurping data from your file system (such as in a backup file) up into your target database. One is to use 'source' command and the other is to use the < redirection operator.

    Option 1: from the directory where your backup file is:

    $mysql -u username -p -h hostname databasename < backupfile.sql
    

    Option 2: from the directory where your backup file is:

    $mysql -u username -p -h hostname
    [enter your password]
    > use databasename;
    > source backupfile.sql
    

    Obviously, both of these options require that you have a backup file that is SQL.

    0 讨论(0)
  • 2020-12-12 11:12

    I believe the easiest way is to upload the file using MYSQL command line.

    using the command from the terminal to access MySQL command line and run source

        mysql --host=hostname -uuser -ppassword
        source filename.sql 
    

    or directly from the terminal

       mysql --host=hostname -uuser -ppassword < filename.sql
    

    at the prompt

    I found this link How to upload big sql dump files (memory, HTTP or timeout problems) in MYSQL. it give the outline of what to do to upload a large SQL. It helped me when I got face with a client 196mb sql dump. Something the PHPMySql couldn't handle.

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