mysql命令导入导出数据_mysql 命令导入导出数据

连接mysql

[root@xxx bin]# ./mysql -uroot -pxxx #进入mysql bin 目录下 -u 用户 -p 密码

创建数据库,并指定utf-8编码

mysql> CREATE DATABASE sr_demo DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Query OK, 1 row affected (0.03 sec)

展示所有数据库

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| fairylandTotal |

| fariylandEpoch |

+--------------------+

3 rows in set (0.00 sec)

进入指定数据库

mysql> use fairylandTotal

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

查看表信息

mysql> show tables;

+----------------------------+

| Tables_in_fairylandTotal |

+----------------------------+

| ACT_EVT_LOG |

| ACT_GE_BYTEARRAY |

| ACT_GE_PROPERTY |

| ACT_HI_ACTINST |

| . . . . . . |

| warn_look |

| warning |

+----------------------------+

125 rows in set (0.15 sec)

source 命令导入sql文件

mysql> source /home/console/xxxx.sql #source 命令后面跟上需要执行sql脚本的路径

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.03 sec)

. . . . . . . . . . .

Query OK, 0 rows affected (0.01 sec)

linux 环境下需要进入到mysql bin 目录下执行(下面所有命令):

Mysql 导入sql文件指定数据库(推荐使用命令)

bin]# ./mysql -urxxx -p 库名 < /home/console/xxx.sql

Enter password:

mysqldump导出命令

导出整个数据库结构和数据(指定导出sql文件路径)

bin]# ./mysqldump -uroot -pxxx 库名 > /home/console/xxx.sql

mysqldump: [Warning] Using a password on the command line interface can be insecure.

导出单个数据表结构和数据(指定导出sql文件名称及位置)

bin]# ./mysqldump -uroot -pxxxx 库名 表名 > /home/console/xxx.sql

mysqldump: [Warning] Using a password on the command line interface can be insecure.

导出整个数据库结构(不包含数据,指定导出sql文件名称及位置)

bin]# ./mysqldump -uroot -pxxxx -d 库名 > /home/console/xxx_structure.sql

mysqldump: [Warning] Using a password on the command line interface can be insecure.

导出单个数据表结构(不包含数据,指定导出sql文件名称及位置)

bin]# ./mysqldump -uroot -pxxxx -d 库名 表名 > /home/console/xxx_structure.sql

mysqldump: [Warning] Using a password on the command line interface can be insecure.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值