mysqldump--导出工具
#导出单个数据库:结构 无数据
[root@localhost ~]#mysqldump -h127.0.0.1 -uroot -p --opt --no-data db_name >~/db_name.sql
#导出单个数据库:有数据 无结构
[root@localhost ~]#mysqldump -h127.0.0.1 -uroot -p --opt --no-create-info db_name >~/db_name.sql
#导出单个数据库:结构+数据
[root@localhost ~]#mysqldump -h127.0.0.1 -uroot -p --opt db_name >~/db_name.sql
#导出单个数据库:结构+数据+函数+存储过程
[root@localhost ~]#mysqldump -h127.0.0.1 -uroot -p --opt -R db_name >~/db_name.sql
#导出多个数据库:结构
[root@localhost ~]#mysqldump -h127.0.0.1 -uroot -p --opt --databases db_name1 db_name2 >~/db_name.sql
#导出单个表:结构 无数据
[root@localhost ~]#mysqldump -h127.0.0.1 -uroot -p --opt --no-data -d db_name table>~/table_name.sql
#导出单个表:结构 包含数据
[root@localhost ~]#mysqldump -h127.0.0.1 -uroot -p --opt dbname tablename>~/tablename.sql
mysql导入:
[root@localhost ~]#
mysql -u root -p
[root@localhost ~]#
use 要导入的数据库
[root@localhost ~]#source /home/1.sql
或者
[root@localhost ~]#
mysql -u root -p<
/home/1.sql