First of all, connect to your server via SSH and login as root/elevate yourself to root status. Here is the command we are going to use:
mysql -u user -p password -h host database_name < backupfile.sql
or
mysql -u user -p database_name < backupfile.sql
when you run this command
it asked password
You need to change the bold sections. A brief explanation of each:
- user: The user who has access to the database you are importing data into
- password: Password of the user
- host: The database host. This is usually localhost
- database_name: Name of the database you want to import data into
- backupfile.sql – Name/location of the backup file you want to import.
Here is a proper example:
mysql -u john -p johnspass -h localhost johns_db < /home/john/backups/backup.sql
or
mysql -u john -p johns_db < /home/john/backups/backup.sql
In this example, we are importing the file backup.sql into the database johns_db, using the user john, and the database host is localhost.
This could take a while depending on the size of the database. Once you are returned to the command line, the import has been completed. It is a good idea to check in phpMyAdmin or a similar tool to make sure that the database imported correctly.