centos7.8---yum安装mysql5.7.36

采得百花成蜜后,为谁辛苦为谁甜。这篇文章主要讲述centos7.8---yum安装mysql5.7.36相关的知识,希望能为你提供帮助。
1.系统版本

[root@test001 ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[root@test001 ~]#

2.查看有无Mariadb的包,并卸载它
[root@test001 ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.65-1.el7.x86_64
[root@test001 ~]# rpm -e mariadb-libs-5.5.65-1.el7.x86_64 --nodeps

3.下载mysql rpm的官方yum源
[root@test001 ~]# wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
[root@test001 ~]# yum -y install mysql57-community-release-el7-10.noarch.rpm
[root@test001 ~]# yum -y install mysql-community-server

配置MySQL
[root@test001 ~]# systemctl startmysqld.service
[root@test001 ~]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2021-12-05 16:29:12 CST; 30s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 3939 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 3881 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 3942 (mysqld)
Tasks: 27
CGroup: /system.slice/mysqld.service
└─3942 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

12月 05 16:29:07 test001 systemd[1]: Starting MySQL Server...
12月 05 16:29:12 test001 systemd[1]: Started MySQL Server.
[root@test001 ~]#




找出MySQL的密码:

[root@test001 ~]# grep "password" /var/log/mysqld.log
2021-12-05T08:29:10.359197Z 1 [Note] A temporary password is generated for root@localhost: *********
[root@test001 ~]#


此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库
其中‘new password’替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/; :等),不然不能配置成功



开启mysql的远程访问 执行以下命令开启远程访问限制,我开启的是允许所有用户访问




4.关闭防火墙
[root@test001 ~]# systemctl stop firewalld
[root@test001 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@test001 ~]#



[root@test001 ~]# vi /etc/selinux/config






【centos7.8---yum安装mysql5.7.36】重启服务器。
[root@test001 ~]# systemctl start mysqld
[root@test001 ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2021-12-05 16:43:22 CST; 1min 54s left
Docs: man:mysqld(

    推荐阅读