Linux虚拟机安装MySQL8.0

替换yum源(如果不是虚拟机不用替换)

curl -o /etc/yum.repos.d/CentOS-Base.repo mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all
yum makecache

一、

在线安装mysql(网速不好会有点慢)
下载安装包:

yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

安装

yum install mysql-community-server -y

二、

本地安装(与在线安装二选一)
下载压缩文件
mysql-80.11-1.el7.86_64.rpm-bundle.tar
解压缩tar文件

tar xvf mysql-80.11-1.el7.86_64.rpm-bundle.tar

 安装第三方依赖包

yum install perl -y
yum install net-tools -y

查看mariadb

rpm -qa|grep mariadb

结果:mariadb-libs-5.5.60-1.el7_5.x86_64
卸载

rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps

 本地安装MySQL

rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm

三、

修改/var/lib/mysql目录访问权限

chmod -R 777 /var/lib/mysql/

初始化

mysqld --initialize
chmod -R 777 /var/lib/mysql/*

 启动数据库(在线安装mysql本地安装mysqld,我在线安装初始化后访问权限用的mysqld)

service mysql / mysqld start

查看密码

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

 本地登录(刚安装是没有远程访问权限的)

mysql-u root -p
"查看的初始密码,时间最新的一个"

修改密码

alter user user() identified by "123456"; 

 设置MySQL允许远程连接

use mysql;
update user set host ='%' where user ='root';
flush privileges;

 退出mysql编辑
exit
修改MySQL配置文件

vi /etc/my.cnf

 在[mysqld]后添加

character_set_server = utf8
bind-address=0.0.0.0

 重启MySQL(同上)

service mysql / mysqld restart

系统防火墙开放3306端口
设置:

firewall-cmd --zone=public --add-port=3306/tcp --permanent

应用:

firewall-cmd --reload 

完毕。 

远程连接要用最新版本的Navicat(mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password )

如果不想安装最新的Navicat可以修改MySQL8.0的加密规则:

登录设置:

mysql-u root -p
"password"

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

刷新配置,重启(同上)MySQL

flush privileges;
service mysql / mysqld restart;

 

你可能感兴趣的:(数据库,虚拟机,运维,mysql数据库安装)