Some commands to help working with MySQL easier

Some commands to help working with MySQL easier

The following commands may help you save your time when it comes to backup, restore or repair your MySQL database.

1. Export a database:

You can also export and compress a database as well:

2. Import a database from file:

3. Import a gzipped SQL file to a database:

4. Backup a database, compress it and send to remote server:

5. Check, optimize and repair a database if it is corrupted:

6. Monitor MySQL restore progress with pv: Instead of using:

Use:

To monitor a backup progress:

*Note: if you don’t have pv command on your system yet, you can install it by using ‘yum install pv’ (for RHEL/Centos) or ‘apt-get install pv’ (for Debian/Ubuntu)

7. Duplicate a database Of course you can export the database and import it to another database, but this is a cleaner one-liner that works. No intermediate file needed. First you need to create a new database (db2). Then copy data from an existing database (db1) to db2 using:

 

SSS Full-stack Engineer

Love Silicon Straits and want to know more about our company culture, working environment or job vacancies?
Find out more at careers.siliconstraits.vn.

Silicon Straits
Be Challenged. Be Inspired. Be Different.




Posted by

on April 16, 2014

in , ,

Comments

Follow us for more later

or subscribe with