CentOS MYSQL : Exporting and Importing

The default file location for MYSQL in CentOS is /var/lib/mysql. The following tutorial will assume that you are working from this directory.

Export a database using the following command:

[user@localhost ~]$ mysqldump -u root -p dbname > file.sql

Import a file to an existing mysql database using the following command:

[user@localhost ~]$ mysql -u root -p dbname < file.sql

In both cases you will be prompted for the root password you established when setting up the mysql service.

Posted in Learn, Linux