• 4
name Punditsdkoslkdosdkoskdo

How do I load a sql.gz files to my database? (importing)

I'm trying to import a gzipped SQL file into mysql directly. Is this the right way?

mysql -uroot -ppassword mydb > myfile.sql.gz

To display a progress bar while importing a sql.gz file, download pv and use the following:

pv mydump.sql.gz | gunzip | mysql -u root -p

In CentOS/RHEL, you can install pv with yum install pv.

In Debian/Ubuntu apt-get install pv.

In MAC, brew install pv

  • 0
Reply Report
zcat /path/to/file.sql.gz | mysql -u 'root' -p your_database

> will write the output of the mysql command on stdout into the file myfile.sql.gz which is most probably not what you want. Additionally, this command will prompt you for the password of the MySQL user "root".

  • 0
Reply Report