1.新建组、新建用户
[root@ticent admin]# groupadd MySQL
[root@ticent admin]# useradd -m -g mysql mysql
[root@ticent admin]#
2.查看是否已经安装,如已经安装,需要先移除
[root@ticent admin]# rpm -qa | grep mysql
[root@ticent admin]#
3.修改mysql用户密码
[root@ticent admin]# passwd mysql
4.下载
[mysql@ticent ~]$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.18-1.el7.x86_64.rpm
[mysql@ticent ~]$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.18-1.el7.x86_64.rpm
[mysql@ticent ~]$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.18-1.el7.x86_64.rpm
[mysql@ticent ~]$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.18-1.el7.x86_64.rpm
[mysql@ticent ~]$ ll
总用量 157960
-rw-rw-r--. 1 mysql mysql 25079412 3月 20 17:40 mysql-community-client-5.7.18-1.el7.x86_64.rpm
-rw-rw-r--. 1 mysql mysql 277784 3月 20 17:40 mysql-community-common-5.7.18-1.el7.x86_64.rpm
-rw-rw-r--. 1 mysql mysql 2237888 3月 20 17:40 mysql-community-libs-5.7.18-1.el7.x86_64.rpm
-rw-rw-r--. 1 mysql mysql 128210634 6月 6 01:02 mysql-community-server-5.7.18-1.el7.x86_64.rpm
5.可以使用root用户安装,也可以使用mysql用户安装。若使用mysql,则需要先修改/etc/sudoers文件,如下,添加标记的内容。使用root则不需要设置。
[root@ticent admin]# vi /etc/sudoers
6.移除mariadb-libs
[mysql@ticent ~]$ sudo rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps
7.安装perl
[root@ticent mysql]# yum install perl
8.安装mysql
[mysql@ticent ~]$ sudo rpm -ivh mysql-community-common-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-common-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-common-5.7.18-1.e################################# [100%]
[mysql@ticent ~]$ sudo rpm -ivh mysql-community-libs-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-libs-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-libs-5.7.18-1.el7################################# [100%]
[mysql@ticent ~]$ sudo rpm -ivh mysql-community-client-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-client-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-client-5.7.18-1.e################################# [100%]
[mysql@ticent ~]$ sudo rpm -ivh mysql-community-server-5.7.18-1.el7.x86_64.rpm
警告:mysql-community-server-5.7.18-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql-community-server-5.7.18-1.e################################# [100%]
9.初始化
[mysql@ticent ~]$ mysqld --initialize
10.启动服务
[mysql@ticent ~]$ service mysqld start
11.查看临时密码
[mysql@ticent ~]$ cat /var/log/mysqld.log
12.使用初始密码登录,修改密码
[mysql@ticent ~]$ mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123';
专注于为中小企业提供网站建设、成都做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业偏关免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了1000+企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
mysql> flush privileges;
13.再次登录验证成功