How to Import MySQL Databases in Command Line
In this tutorial, we will go over the process that how to upload a database in the command line. In this method, you can import the large size of the database in phpmyadmin. You can easily upload over a 50MB database (SQL) file.
Why did you need to upload via command mode?
As a cPanel user, you can easily upload the database SQL file to use phpmyadmin import tab. For an offshore hosting user or other application users, the database file size can be more than 50MB. For example, if you have a movie download site and use an offshore hosting using to manage a VPS or a dedicated server, most of the time your database size more than 50MB and you failed to import the SQL file using phpmyadmin.
Importing a Database via SSH
Please follow a few steps to import your large database in a command line.
- First, please create a database, database user and connect the database with the user and select the permissions also in your cPanel.
- Upload the SQL file(file_name.sql) to cPanel public folder which name is “public_html“.
- Make sure you have root access to connect SSH by Putty. And open the terminal.
- Now browse the public_html folder in this command line. Please replace the user name (cpanel_user) of the cPanel from the command line.
- And Now run this command to start import the SQL file to your database of phpmyadmin. Make sure the replace of following names.
dbuser = your database user name that you pointed on the database in cPanel.
dbname = Your database name that you created in cPanel.
file_name.sql = The SQL file that you uploaded in cPanel public_html folder.
mysql -p -u db_user dbname < file_name.sql
Congratulations you have now imported your SQL file into your database. If you had any issues along the way please let us know by commenting below.
Leave a Reply