用rpm包在centos7.4上安装mysql-5.7.29-1.el7.x86_64

一,准备工作。

查看系统版本:

[ ~]# uname -a
Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[ ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core) 
[ ~]#

mysql的rpm包下载地址

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

用rpm包在centos7.4上安装mysql-5.7.29-1.el7.x86_64

下载,mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar 大小520.5M

卸载CentOS7.4系统自带的mariadb

[ ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[ ~]# rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
[ ~]# rpm -qa|grep mariadb
[ ~]#

将mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar 拷贝到/tmp下,并解压

用rpm包在centos7.4上安装mysql-5.7.29-1.el7.x86_64

解压

[ tmp]# tar xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar 
mysql-community-embedded-devel-5.7.29-1.el7.x86_64.rpm
mysql-community-test-5.7.29-1.el7.x86_64.rpm
mysql-community-embedded-5.7.29-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.29-1.el7.x86_64.rpm
mysql-community-libs-5.7.29-1.el7.x86_64.rpm
mysql-community-client-5.7.29-1.el7.x86_64.rpm
mysql-community-server-5.7.29-1.el7.x86_64.rpm
mysql-community-devel-5.7.29-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.29-1.el7.x86_64.rpm
mysql-community-common-5.7.29-1.el7.x86_64.rpm

依次安装:

mysql-community-common-5.7.29-1.el7.x86_64.rpm、
mysql-community-libs-5.7.29-1.el7.x86_64.rpm、
mysql-community-client-5.7.29-1.el7.x86_64.rpm、
mysql-community-server-5.7.29-1.el7.x86_64.rpm

安装common

[ tmp]# rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-common-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.29-1.e################################# [100%]
[ tmp]#

安装libs

[ tmp]# rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-libs-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.29-1.el7################################# [100%]
[ tmp]#

安装client

[ tmp]# rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-client-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.29-1.e################################# [100%]
[ tmp]#

安装server

[ tmp]# rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm 
warning: mysql-community-server-5.7.29-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.29-1.e################################# [100%]
[ tmp]#

这一步如如果报错,缺依赖的问题,需要挂载CentOS7.4的系统iso镜像,安装perl依赖、net-tools依赖

重启系统,来启动mysql服务

[ tmp]# reboot

 查看防火墙端口,开放3306端口

[ ~]# firewall-cmd --query-port=3306/tcp
no
[ ~]# firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[ ~]# firewall-cmd --reload
success
[ ~]# firewall-cmd --query-port=3306/tcp
yes
[ ~]#

 设置数据库日志过期天数为14天

用rpm包在centos7.4上安装mysql-5.7.29-1.el7.x86_64

获取mysql的root用户的初始密码

[ ~]# grep ‘password‘ /var/log/mysqld.log 
2020-01-14T01:09:01.515663Z 1 [Note] A temporary password is generated for : vx*biwua,8/Q
[ ~]#

以获取mysql的root用户的初始密码登录数据库

[ ~]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.29

修改root密码

mysql> alter user ‘root‘@‘localhost‘ identified by ‘2020root$PWD‘;
Query OK, 0 rows affected (0.01 sec)

mysql>

使密码即时生效

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>

允许以root身份远程登录mysql

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘2020root$PWD‘ WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>

修改mysql的字符集为utf8
编辑文件/etc/my.conf,设置字符集为utf8

vi /etc/my.cnf

用rpm包在centos7.4上安装mysql-5.7.29-1.el7.x86_64

重起mysql服务

[ ~]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[ ~]#

测试登陆

用rpm包在centos7.4上安装mysql-5.7.29-1.el7.x86_64

相关推荐