centos7中安装mysql-创新互联
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';
mysql> flush privileges;
13.再次登录验证成功
文章名称:centos7中安装mysql-创新互联
网站网址:http://ybzwz.com/article/cddpcd.html