标签:
mysql
mysqldump
mysqldump -u$USER -p$PASSWD -h127.0.0.1 -P3306 --routines --default-character-set=utf8 --lock-all-tables --add-drop-database -A > db.all.sql
mysqldump -u$USER -p$PASSWD -h127.0.0.1 -P3306 --routines --default-character-set=utf8 --databases mysql > db.sql
mysqldump -u$USER -p$PASSWD -h127.0.0.1 -P3306 --routines --default-character-set=utf8 --tables mysql user> db.table.sql
mysqldump -u$USER -p$PASSWD -h127.0.0.1 -P3306 --routines --default-character-set=utf8 --no-create-db --no-create-info --tables mysql user --where="host=‘localhost‘"> db.table.sql
mysqldump -u$USER -p$PASSWD -h127.0.0.1 -P3306 --routines --default-character-set=utf8 --no-data --databases mysql > db.nodata.sql
mysql -u$USER -p$PASSWD -h127.0.0.1 -P3306 --default-character-set=utf8 --skip-column-names -B -e ‘select user,host,password from mysql.user;‘ > mysql_user.txt
SELECT user,host,password FROM mysql.user INTO OUTFILE ‘/tmp/mysql_user.csv‘ FIELDS TERMINATED BY ‘,‘;
第一种方法:
mysql -u$USER -p$PASSWD -h127.0.0.1 -P3306 --default-character-set=utf8 < db.all.sql
第二种方法:
登录MySQL,执行source命令,后面的文件名要用绝对路径.
......
mysql> source /tmp/db.all.sql;
第一种方法:
mysql -u$USER -p$PASSWD -h127.0.0.1 -P3306 --default-character-set=utf8 mysql < db.table.sql
第二种方法:
登录MySQL,执行source命令,后面的文件名要用绝对路径.
mysql -u$USER -p$PASSWD -h127.0.0.1 -P3306 --default-character-set=utf8
......
mysql> use mysql;
mysql> source /tmp/db.table.sql;
mysql -u$USER -p$PASSWD -h127.0.0.1 -P3306 --default-character-set=utf8
......
mysql> use mysql;
mysql> LOAD DATA INFILE ‘/tmp/mysql_user.txt‘ INTO TABLE user ;
mysql -u$USER -p$PASSWD -h127.0.0.1 -P3306 --default-character-set=utf8
......
mysql> use mysql;
mysql> LOAD DATA INFILE ‘/tmp/mysql_user.csv‘ INTO TABLE user FIELDS TERMINATED BY ‘,‘;
mysql -u$USER -p$PASSWD -h127.0.0.1 -P3306 --default-character-set=utf8
......
mysql> use mysql;
# txt
mysql> LOAD DATA LOCAL INFILE ‘/tmp/mysql_user.csv‘ INTO TABLE user;
# csv
mysql> LOAD DATA LOCAL INFILE ‘/tmp/mysql_user.csv‘ INTO TABLE user FIELDS TERMINATED BY ‘,‘;
标签:
原文地址:http://www.cnblogs.com/tiandao/p/5022042.html