接下来需要在slave2上安装MySQL

软件

mysql-community-client-8.0.18-1.el7.x86_64.rpm
mysql-community-common-8.0.18-1.el7.x86_64.rpm
mysql-community-libs-8.0.18-1.el7.x86_64.rpm
mysql-community-server-8.0.18-1.el7.x86_64.rpm 
mysql-connector-java-8.0.18-1.el7.noarch.rpm

下载

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-libs-8.0.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-common-8.0.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-client-8.0.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-community-server-8.0.18-1.el7.x86_64.rpm
wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.18-1.el7.noarch.rpm

安装

rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-connector-java-8.0.18-1.el7.noarch.rpm

启动

systemctl start mysqld

查看启动状态

systemctl status mysqld

开机启动

systemctl enable mysqld

查看初始root密码

cat /var/log/mysqld.log | grep password

屏幕快照 2019-11-25 下午9.56.04.png
把密码记录下来,接下来登陆需要输入

登陆MySQL

mysql -u root -p

输入上面记录的密码

改变root的登陆密码

use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Root@123';

允许非本机登陆

update user set host='%' where user='root';
grant all privileges on *.* to 'root' with grant option;
flush privileges;

添加hivedb用户

create user hivedb identified by 'Hivedb@123';
grant all privileges on *.* to 'hivedb' with grant option;
flush privileges;

查看user table可以看到
屏幕快照 2019-11-25 下午10.17.57.png
hivede用户的Host为%允许网络访问

确认

mysql -u hivede -p -h 192.168.21.163

输入用户密码登陆执行

show databases;

如果是从低版本升级到MySQL8.0的我出现一些奇怪问题,最后通过彻底删除之前版本,删除目录才解决

rpm -qa | grep mysql

删除上面列出的所有mysql的包

rpm -e xxxx

删除所有目录

find / -name mysql

删除上面列出的所有mysql目录

尤其需要确认一下
在/etc/my.cnf中
pid-file=/var/run/mysqld/mysqld.pid
指定的mysqld.pid文件删除了


麦穗儿
127 声望15 粉丝

程序猿以技术为本