简体   繁体   中英

Import .sql file to mysql database

I am trying to import a .sql file to mysql database. The size of mysql file is around 90MB.

I also found a similar question how to import .sql file in mysql database using php

I am using this script which is similar to the other one

$mysqlDatabaseName = 'db_test';
$mysqlUserName = 'db_dev';
$mysqlPassword = '1234abcd';
$mysqlHostName = 'localhost';
$mysqlImportFilename = 'dbbackup.sql';
$command = 'mysql -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p' .$mysqlPassword .' ' .$mysqlDatabaseName .' < ' .$mysqlImportFilename;
    exec($command,$output = array(),$worked);
    switch($worked){
        case 0:
            echo "Import file ".$mysqlImportFilename." successfully imported to database ".mysqlDatabaseName.";
        break;
        case 1:
            echo 'There was an error during import. Please make sure the import file is saved in the same folder as this script.';
        break;
    }

I am getting the following error

There was an error during import. Please make sure the import file is saved in the same folder as this script.

How can i fix it ??

Check the file system path of your dump file and place it in this line of the code your regarded:

$mysqlImportFilename = '/path/to/the/file/dbbackup.sql';

For large size: Increase your some of your PHP settings, php.ini, such as memory limit and maximum execution time

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM