首页 > 代码库 > MySQL 在云主机上搭建主从
MySQL 在云主机上搭建主从
1:已经事先购买了两台云主机
10.4.14.168 101.69.178.208 [联通] Master
10.4.5.9 101.69.178.219 [联通] Slave
2:分别安装MySQL
#yum install mysql-server –enablerepo=remi
#yum install mysql-devel
3:查看MySQL安装情况
[root@10-4-14-168 ~]# rpm -qa | grep mysql*
mysql-5.1.73-3.el6_5.x86_64
mysql-libs-5.1.73-3.el6_5.x86_64
mysql-server-5.1.73-3.el6_5.x86_64
mysql-devel-5.1.73-3.el6_5.x86_64
mysql-libs-5.1.73-3.el6_5.x86_64
mysql-server-5.1.73-3.el6_5.x86_64
mysql-devel-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)
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)
MySQL 在云主机上搭建主从
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。