Tools
Back up and restore the MySQL database using the command line on Web Help Desk
This article describes how to back up and restore the external MySQL database using the command line.
First published date
Last published date
Overview
Product section
Cause
Resolution
Back up the MySQL database
Windows Server
- Open a command prompt.
- In the window, execute:
Go to the MySQL bin folder, cd "C:\Program Files\MySQL\MySQL Server 5.6\bin" or "C:\Program Files\MySQL\MySQL Server 5.7\bin"
- Back up the database. Execute:
mysqldump --user=whd --password --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database whd > C:\WHDMySQL\whdbackup.sql
- Enter prompted for a database password.
Linux or Virtual Appliance
- Download and start PuTTY or another SSHv2 client on your Windows PC
- Connect to the Linux server.
If you are connecting to a virtual appliance, connect as the useradmin. - In Linux, switch to
rootuser or any user withsudoprivileges.
In the Virtual Appliance, entersudo su. - Back up the database. Execute:
mysqldump -u whd -p -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B whd > /data1/whdbackup.sql Note: /data1/ is a folder available on Linux WHD appliance, your backup folder may be different if using other CentOS installation. You may create your own backup folder.
Enter thewhd database user passwordif prompted for a database password.
Restore the MySQL database
Windows Server
- Open a command prompt.
- Go to the MySQL bin folder,
cd "C:\Program Files\MySQL\MySQL Server 5.6\bin"
or
"C:\Program Files\MySQL\MySQL Server 5.7\bin" - Restore the database.
Execute:
mysql -u whd -p whd < C:\whdbackup.sql - Enter the
whd database user passwordif prompted for a database password.
Linux or Virtual Appliance
- Connect to the Linux server.
If you are connecting to a virtual appliance, connect as the useradmin. - Connect to the Linux server.
If you are connecting to a virtual appliance, connect as the useradmin. - In Linux, switch to
rootuser or any user withsudoprivileges.
In the Virtual Appliance,entersudo su. - Restore the database. Execute:
mysql -u whd -p whd < /data1/whdbackup.sql
Enterwhd database user passwordif prompted for a database password.
Disclaimer: Scripts are not supported under any SolarWinds support program or service. Scripts are provided AS IS without warranty of any kind. SolarWinds further disclaims all warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The risk arising out of the use or performance of the scripts and documentation stays with you. In no event shall SolarWinds or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the scripts or documentation.