How do I import a MySQL Database?
As with exporting your database to another server, importing it too is vital to keep your website up and running without any hassles. As a prerequisite, you will have to have already created a new database with all the necessary database structures included, so as to make the import process smoother. This can be done using phpAdmin from cPanel. In another method, you can import databases through command line (SSH).
Importing Databases via phpMyAdmin
1. Log in to your cPanel account.
2. Navigate to Databases.
The Database section will be displayed.
3. Click phpMyAdmin Databases.
The phpMyAdmin Databases page will be displayed.
You will find the list of available databases.
4. Click Import.
5. Click Choose File and select the file in .SQL or .ZIP format from your computer.
6. Select the Format as SQL from the drop down list.
7. Click Go.
Importing Databases via Command Line (SSH)
You can also import the database using your SSH login credentials. In this case, your database file must be in SQL format only.
- Using cPanel’s File Manager, or FTP client, upload the database to home directory.
- If the database is not available, create a new database, a user, and give the user full privileges to the database.
- Log into your server via SSH.
- Use the command to verify that the file is in your current directory.
- In the following command, replace the ‘user_name’, ‘database_name, and ‘file.sql’ with the correct values for your database and file:
- mysql -p -u user_namedatabase_name<file.sql< li=””></file.sql<>
- Enter the database user password.
Note: If the file is not present, upload/move the file to the correct directory, or navigate to the directory where the file is located.
Your database will be imported.