is this right?
mysql -uroot -ppassword mydb < myfile.sql.gz
Straight and clear:
gunzip -c myfile.sql.gz | mysql -uroot -ppassword mydb
-c option for gunzip writes to stdout, keeps original files
NOTE: You shouldn't put the password directly in the command. It's better to provide just -p and than enter the password interactively.
password
directly in the terminal, use without it like followszcat YOUR_FILE.sql.gz | mysql -u YOUR_DB_USERNAME -p YOUR_DATABASE_NAME
Use the following command:
gunzip < databasefile.sql.gz | mysql -u root -p dbname
For Generating dbName.sql.gz
mysqldump -u <YOUR USERNAME> -p<YOUR PASSWORD> <YOUR DBNAME> | gzip > ~/mysqlBackup/dbName_`date +%Y%m%d%H%M`.sql.gz
For Loading dbName.sql.gz
zcat ~/mysqlBackup/<.SQL.GZ file> | mysql -u <YOUR USERNAME> -p<YOUR PASSWORD> <DATABASE NAME IN WHICH YOU WANT TO LOAD>
tar -xzf myfile.tar.gz
Check the extracted sql files using: ls
mysql -u root -p password database < myfile.sql
You have to follow below steps:
First check Mysql service should be running.
Then if you have compressed file, decompress it first.