首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

mysql backup tool mysqldump

前言

配置mysql主从复制时,要用到mysqldump工具。本文初步熟悉此工具的必要用法,便于快速部署mysql主从复制。

结论

1,mysqldump --all-databases导出全部数据库

2,drop database无法删除performance_schema

3,/mysql -u root -p

部署明细

1,创建测试表

[root@mygirl ~]# /usr/local/mysql/bin/mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 10

Server version: 5.5.58-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

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

Database

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

information_schema

mysql

newdb

newzxy

performance_schema

test

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

6 rows in set (0.00 sec)

mysql> use newzxy;

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> create table t_newtab(a int);

Query OK, 0 rows affected (0.04 sec)

mysql> insert into t_newtab values(1);

Query OK, 1 row affected (0.01 sec)

2,导出全部数据库

[root@mygirl ~]# /usr/local/mysql/bin/mysqldump --all-databases -u root -p >fulldbdump.db

Enter password:

-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.

[root@mygirl ~]# ll fulldbdump.db

-rw-r--r--. 1 root root 1613359 Jan 1 16:07 fulldbdump.db

3,删除全部数据库,可见无法删除数据库performance_schema

mysql> show databases;

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

Database

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

information_schema

mysql

newdb

newzxy

performance_schema

test

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

6 rows in set (0.00 sec)

mysql> drop database mysql;

Query OK, 24 rows affected, 2 warnings (0.03 sec)

mysql> drop database newdb;

Query OK, 2 rows affected, 2 warnings (0.02 sec)

mysql> drop database newzxy;

Query OK, 2 rows affected, 2 warnings (0.01 sec)

mysql> drop database test;

Query OK, 2 rows affected, 2 warnings (0.03 sec)

mysql> drop database information_schema;

ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'information_schema'

mysql> drop database performance_schema;

Query OK, 17 rows affected, 2 warnings (0.00 sec)

4,导入全部数据库

[root@mygirl ~]# /usr/local/mysql/bin/mysql -u root -p

Enter password:

[root@mygirl ~]#

5,验证数据库导入是否正确

[root@mygirl ~]# /usr/local/mysql/bin/mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 14

Server version: 5.5.58-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

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

Database

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

information_schema

mysql

newdb

newzxy

test

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

5 rows in set (0.00 sec)

mysql> use newzxy;

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_newzxy

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

t_big

t_newtab

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

2 rows in set (0.00 sec)

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180101G0MGUC00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券