本来打算直接用原生yum源安装,但是跨国访问网络太慢,只好采用离线安装的方式,原理就是把所需的rpm下载下来再上传服务器安装。
1、rpm文件下载地址:
目录: http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/
具体文件:
http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.28-1.el7.x86_64.rpm
http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.28-1.el7.x86_64.rpm
http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm
http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.28-1.el7.x86_64.rpm
http://repo.mysql.com/yum/mysql-connectors-community/el/7/x86_64//mysql-connector-odbc-8.0.18-1.el7.x86_64.rpm
http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.28-1.el7.x86_64.rpm
http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.28-1.el7.x86_64.rpm
2、安装依赖环境
yum -y install numactl
3、卸载mariadb
[root@hadoop ~]# rpm -qa|grep mariadb mariadb-libs-5.5.52-1.el7.x86_64 [root@hadoop ~]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64 [root@hadoop ~]# rpm -qa|grep mariadb
3、安装原生yum源(非必选)
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm yum localinstall mysql57-community-release-el7-8.noarch.rpm
4、安装mysql rpm
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm rpm -ivh mysql-community-devel-5.7.28-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-compat-5.7.28-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm rpm -ivh mysql-connector-odbc-8.0.18-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
5、启动mysql服务器
service mysqld start
6、修改密码
mysql默认给root账号配置了临时密码,需要手动改成自己的
查看方式:
cat /var/log/mysqld.log | grep password 2019-12-22T08:14:59.578240Z 1 [Note] A temporary password is generated for root@localhost: !Ml,ThwaB0d_
其中末尾的“!Ml,ThwaB0d_”就是password
登录mysql:mysql -uroot -p
修改密码策略(防止不能设置自己想设置的密码,如果想要设置的密码复杂度够,可以跳过):
set global validate_password_policy=0; set global validate_password_length=1;
修改密码:
alter user 'root'@'localhost' identified by '1234'; flush privileges;
7、允许远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1234' WITH GRANT OPTION; FLUSH PRIVILEGES;