Knowledgebase article 134

How to backup (and restore) your MySQL Database

This article contains instructions to back up your mySQL database using the command line or an optional graphical utility.

To make a backup with the command line (no additional software needed):

Notes: These commands need to be run from the mysql/bin directory.  Any MySQL command may need a specific socket file to be used.  If you get a missing sock file error please add the following to your command: --protocol=socket --socket=/tmp/GLmysql.sock.

 1. From a command prompt or run:

mysqldump -u [username] -p [databasename] > [backupfile.sql]

(example Linux version of this command below:)

./mysqldump -u root -p ehelpdesk > /ehdbackup.sql

username = your database username (typically root).
databasename = the schema name of your database (typically ehelpdesk)
backupfile.sql = the file to which the backup should be written (you can name this whatever you want).

2.  To restore or import your database, at command or termianl run:
Mysql –u [username] –p [databasename] < [backupfile.sql]

In order for this command to work, a blank database must exist with the specified name (see above for additional notes).


To make a backup using mySQL Workbench (download required) on Windows and Linux:

This graphical tool is easy to use if you do not feel comfortable with the command line, or need additional features. This tool can be used to remotely manage and backup your database via your network.  MmySQL Workbench can be obtained from:

1.  From the Home screen, click the "Server Administration" link.

2.  Select your server and enter user name and password.

3.  Click "Data Export and Restore" link.

4.  Select the desired schema, and options, and click "Start Export" command button.  The same tool is used to Import databases.

Group eHD Standard Support Last modified Nov 13, 2019 Type Public Viewed 8735