centos7通过yum安装mysql

271 阅读1分钟

参考来源:www.cnblogs.com/ianduin/p/7…

1.首先配置mysql的yum源

在MySQL官网中下载YUM源rpm安装包:https://dev.mysql.com/downloads/repo/yum/



# 下载mysql源安装包
shell>  wget http://repo.mysql.com/mysql80-community-release-el7-3.noarch.rpm 
# 安装mysql源
shell> yum localinstall mysql80-community-release-el7-3.noarch.rpm 


检查yum源是否安装好


2、安装MySQL

shell> yum install mysql-community-server

3、启动MySQL服务

shell> systemctl start mysqld

查看MySQL的启动状态

shell> systemctl status mysqld


4、开机启动

shell> systemctl enable mysqld
shell> systemctl daemon-reload

5、修改root本地登录密码


mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:

shell> grep 'temporary password' /var/log/mysqld.log


登录

mysql -uroot -pXXX;

use mysql;

create user 'root'@'%' identified by 'Root_root123'; 

grant all privileges on *.* to 'root'@'%' with grant option; 

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Root_root123'; 

这样就可以通过主机的navicat访问了。

还有处理防火墙的问题,我这边是直接关掉防火墙。

yum install lsof 


 [root@localhost ~]# getenforce 

 Enforcing

root@localhost ~]# setenforce 0

 [root@localhost ~]# getenforce 

 Permissive 

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


[root@localhost ~]# getenforce

 Permissive

[root@localhost ~]# systemctl disable firewalld