Let’s say you have a very large MySQL database and you are moving it to a new server ( or just moving your whole website to a new web host ) and of course your cannot import it from phpMyAdmin.
This is a tutorial to show you the easiest way to import a very large MySQL database from your shell/terminal. First of all you need to upload the MySQL backup the your server and go to that location:
mysql -u username -ppassword databasename < databasebackup.sql
The command is pretty easy to understand.
The -u parameter is the mysql user you use to connect to your MySQL server.
The -p parameter is the password for the MySQL user. In case your password has special characters ( like $%@&! ) you can enter the password between double quotes: -p"password%!$@#"
In case you need more explanations 🙂 the database name in the command is the name of the MySQL database you use and databasebackup.sql is the name of the file/SQL backup you want to import.
Another easy way is to use the mysql source command to import data:
More info can be found on 18.104.22.168 Executing SQL Statements from a Text File