1:已经事先购买了两台云主机
10.4.14.168 101.69.178.208 [联通] Master
10.4.5.9 101.69.178.219 [联通] Slave
2:分别安装MySQL
代码如下 | 复制代码 |
#yum install mysql-devel |
3:查看MySQL安装情况
代码如下 | 复制代码 |
[root@10-4-14-168 ~]# rpm -qa | grep mysql* mysql-5.1.73-3.el6_5.x86_64 |
4:启动MySQL
代码如下 | 复制代码 |
service mysqld start |
5:登陆MySQL并且修改密码并且删除空用户
代码如下 | 复制代码 |
mysql> UPDATE mysql.user SET password = PASSWORD('ge0513.mysql') -> WHERE user = 'root'; Query OK, 3 rows affected (0.00 sec) Rows matched: 3 Changed: 3 Warnings: 0 mysql> SELECT user,host,password FROM mysql.user; +------+-------------+-------------------------------------------+ | user | host | password | +------+-------------+-------------------------------------------+ | root | localhost | *7AE39BE5035D5C32361400FF7DEDD757AA76896A | | root | 10-4-14-168 | *7AE39BE5035D5C32361400FF7DEDD757AA76896A | | root | 127.0.0.1 | *7AE39BE5035D5C32361400FF7DEDD757AA76896A | | | localhost | | | | 10-4-14-168 | | +------+-------------+-------------------------------------------+ 5 rows in set (0.00 sec) mysql> DROP user ''@localhost; Query OK, 0 rows affected (0.00 sec) mysql> DROP user ''@'10-4-14-168'; Query OK, 0 rows affected (0.00 sec) |
6 需改配置文件
代码如下 | 复制代码 |
bind-address = 10.6.20.1 port = 3306 character_set_server = utf8 max_connect_errors = 1000000 max_connections = 500 datadir = /data/mysql log-error = /var/log/mysql/mysql-error.log-error skip_name_resolve back_log = 2000 log-bin = /data/mysql binlog-format = MIXED expire_logs_days = 2 |
7:主库上创建复制用户
代码如下 | 复制代码 |
GRANT REPLICATION SLAVE ON *.* TO [email protected] IDENTIFIED BY 'gechong'; |
8:在主库上执行
代码如下 | 复制代码 |
mysql> show master status; |
9:在从库的配置文件中添加之后重启服务
代码如下 | 复制代码 |
master-host = 10.4.14.168 master-user = gechong master-password = gechong binlog-do-db = test |
10:在从库上执行
代码如下 | 复制代码 |
mysql> start slave; |
11:尝试在主库上添加新表,看是否从库上也会出现
米加小镇世界龙年无广告版 安卓版v1.81
米加小镇世界龙年无广告是一款模拟类手游,不少的玩家可能都玩过
部落冲突互通服 安卓版v17.100.1
部落冲突互通服是全球风靡的战争策略手游,连接安卓和iOS服务
我的世界恶魔模组资源包 (EDU HELL)最新版vDEATH
我的世界恶魔版是一款像素风格的开放世界沙盒游戏,游戏中你可以
艺术大亨天天拍卖变富翁 最新安卓版v1.31.0
艺术大亨天天拍卖变富翁是一款非常好玩的模拟经营类手游,在游戏
大型巴士司机游戏 安卓版v2.1.0
大型巴士司机是一款模拟驾驶类游戏,玩家们将在游戏中化身为大巴