Skip to content

MySQL Import Local Dump in Linux

For Windows platform, you can also perform an import of a MySQL dump file.

Suppose you already have dump files to be imported, let's do it in Linux.

Prompt for Password

Import the file in the foreground without password.

[root@localhost ~]# cd dumps
[root@localhost dumps]# mysql -u'root' -p database_name < mysql_dump.sql
Enter password:

Explicit Password

Import the file in the foreground with explicit password.

[root@localhost dumps]# mysql -u'root' -p'root_password' database_name < mysql_dump.sql
Warning: Using a password on the command line interface can be insecure.

Background Job

In the foreground, you can monitor the progress of import and solve errors on sight. If the job is a cron job or should take some times, you would be better to do it in the background.

[root@localhost dumps]# nohup mysql -u'root' -p'root_password' database_name < mysql_dump.sql &
[1] 4567
nohup: ignoring input and appending output to `nohup.out'

Leave a Reply

Your email address will not be published. Required fields are marked *