The dreamhost space is used to implement the MYSQL database backup method

  • 2020-05-06 11:45:53
  • OfStack

How to use SSH(Shell) to backup and restore the MySQL database method
For example:
The database parameter is ::
MySQL address: mysql.dh.net
MySQL name :mysql_dbname
MySQL user :mysql_dbuser
MySQL password :mysql_dbpass

I'm going to backup the database to bak.sql

Steps:
Similarly, use telnet with windows or download an putty. After logging in, go all the way to cd to the directory you think is appropriate (make sure the current directory is writable).
Enter the following command:
mysqldump   -h   mysql.dh.net   -p   mysql_dbname   -u   mysql_dbuser   > bak.sql
Then press enter, prompt you to enter the database login password, after entering the password, press enter,OK!   backs up the database to
in the current directory
How to restore bak.sql database :::
Enter the following command and press enter
mysql   -h   mysql.dh.net   -p   mysql_dbname   -u   mysql_dbuser
You are prompted for your password, enter it and press
The MySQL operation prompt symbol
appears Then enter the following command
source   bak.sql
Please first confirm bak.sql and then
in the current directory Enter.OK, restore ing...

Related articles: