Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to dump sql.gz file in to mysql

I have allocated almost all of my space on the production server to my table space

Now i have an compressed dump of around 20gb which is needed to be dumped into mysql

The problem is the server is not having much space to uncompress the file (which requires around 120 gb)

i have used the beolw command but i am a failure because it is first uncompressing the file and then redirecting the output to mysql

 gunzip dbdump.sql.gz | mysql -u root -proot123 -S /home/mysql55/tmp/mysql.sock 

Is there any way so that i can dump the compressed file without uncompressing it

any suggestions are really grateful

like image 648
vidyadhar Avatar asked Mar 26 '13 17:03

vidyadhar


People also ask

How do I unzip a .GZ file in SQL?

You can do this with the following command: gzip -c db-20180518060048. sql.

How do I import a dump file in MySQL?

To import an SQL dump file: Connect to your MySQL database. Choose Import > From SQL Dump… from the File menu. This will bring up a dialog box, select the file on your file system that you would like to import, then click Import . Your database will now be updated.


2 Answers

I know this is ridiculous, but it was gzipped twice, so

  1. Extract filename.sql.gz
  2. Rename extracted file from filename.sql to filename.gz
  3. Extract again

Hope it will work

like image 77
askoura Avatar answered Sep 18 '22 18:09

askoura


You should tell gunzip to write to standard out. What you are doing right now is not going to pipe any output at all.

gunzip -c dbdump.sql.gz | mysql (args...)
like image 39
Andrew Mao Avatar answered Sep 19 '22 18:09

Andrew Mao