Commands on Linux to Import/Export MySQL
Frist login to your server using SSH
then you have to run some commands for import/export MySQL database
Note:you need to know the database username and password
to simulate an exmaple lets consider the following:
- dbusername: cpnluser_user as a database user example, cpnluser as a cPanel username example.
- dbpassword: mypwd123.
- dbname: cpnluser_database as database name
- path to the file: /home/cpnluser/public_html/databases/db_file.sql as location of import/export file path.
Database import
mysql -u cpnluser_user -pmypwd123 cpnluser_database < /home/cpnluser/public_html/databases/db_file.sql
or
mysql -u cpnluser_user -p cpnluser_database < /home/nctests/public_html/cpnluser/db_file.sql
then ssh will ask your for the cpnluser_user password
Database export
mysqldump -u cpnluser_user -pmypwd123 cpnluser_database > /home/cpnluser/public_html/databases/db_file.sql
or
mysqldump -u cpnluser_user -p cpnluser_database > /home/cpnluser/public_html/databases/db_file.sql
then ssh will ask your for the cpnluser_user password