【Linux系列】Centos 7安装 Mysql8.0(五)

目的


本文主要介绍以下两点:

一. 如何安装Mysql8.0

二. Navicat连接Mysql

一. 如何安装Mysql8.0


安装Mysql有两种方式:

直接下载官方的源(比较慢)

https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm # 下载rpm包
yum localinstall mysql80-community-release-el7-1.noarch.rpm # 处理相关依赖
yum install mysql-community-server # 安装

用163的源,分开安装

wget https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-common-8.0.18-1.el7.x86_64.rpm
wget https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-libs-8.0.18-1.el7.x86_64.rpm
wget https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-client-8.0.18-1.el7.x86_64.rpm
wget https://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-server-8.0.18-1.el7.x86_64.rpm

rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm  # rpm下载
rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm

重启Mysql

service mysqld start

查看Mysql默认密码

cat /var/log/mysqld.log | grep password

1

登录

mysql -uroot -p # 回车,复制上面的密码即可

二. Navicat连接Mysql


连接mysql之前,先修改下root的密码

set global validate_password.policy=0; #修改策略
set global validate_password.length=1; 
alter user 'root'@'localhost' identified with mysql_native_password by '12345678'; # 测试环境,密码可以简单点,Mysql8.0必须用mysql_native_password给账号加密

可以exit退出,重新登录看看。

修改root账号的Host,便于IP连接

use mysql; #mysql的基础表
update user set Host = '%' where User='root'; # 正式环境,可以创建新的Mysql账号,设置成具体的ip

开放3306端口

firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --reload

下面用Navicat新建连接,即可

2

posted @ 2019-11-25 10:28  SexyPhoenix  阅读(433)  评论(0编辑  收藏  举报