In a previous post, I explained a couple methods of exporting MySQL databases. Today, we will do just the opposite: import a mysql database. As with the previous example, you may use either phpMyAdmin, your web hosting company’s custom control panel interface (if available), or the Linux command line, if you have the necessary permissions to do so.
To import a mysql database, upload your sql file to your server and login to your server via SSH. Then, enter the following commands:
mysql -p -h localhost dbname < dbname.sql
Replace “dbname” with the name of your database in the first instance and the name of your sql file in the second.
Although this requires more steps, some people might find it easier.
1. Login to phpMyAdmin.
2. Click on your database name.
3. At the top, click “Import”
4. Click “Browse…” and find the sql file on your computer.
5. Click “Go”.
If you are working with a very large sql file, it may timeout in phpMyAdmin, depending on your server’s settings. In such a case, the command line may be a better option.