Wednesday, October 16, 2013

Linux mysql syntax

(Anhgolden's Blog)-Sưu tầm

Export mysql db:
#mysqldump -u [USERNAME] -p [DBNAME] | gzip > [/path_to_file/DBNAME].sql.gz
or
#mysqldump -u [USERNAME] -p [DBNAME] > [/path_to_file/DBNAME].sql
#gzip -d [/path_to_file/DBNAME].sql.gz

Import mysql db:
# gunzip mysqldump.sql.gz
# mysql -u username -p -h localhost test-database < mysqldump.sql
password: _

Use mysql:
#mysql -u [USERNAME] -p
SHOW DATABASES;
DROP DATABASE [DBNAME];
CREATE DATABASE [DBNAME];
USE [DBNAME];
SOURCE [/path_to_file/DBNAME].sql;

No comments:

Post a Comment