Skip to content

How to Import From a MySQL Dump File in Linux

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

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:

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.

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 *