一、下载
1、下载地址:https://dev.mysql.com/downloads/mysql/
2、选择对应的系统版本进行下载
3、把如下包上传到指定的安装目录下
mysql-community-common-8.0.31-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
mysql-community-libs-8.0.31-1.el7.x86_64.rpm
mysql-community-client-8.0.31-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
mysql-community-server-8.0.31-1.el7.x86_64.rpm
二、安装
1、检查 /tmp 目录的权限,如果不是777权限,赋予相应的权限
chmod -R 777 /tmp
2、安装前检查依赖
rpm -qa|grep libaio
rpm -qa|grep net-tools
不存在的话就先安装
yum install libaio
yum install net-tools
3、安装(如下顺序)
rpm -ivh mysql-community-common-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm
注意:安装 mysql-community-libs-8.0.31-1.el7.x86_64.rpm 时可能会报错
执行:yum remove mysql-libs,然后再继续安装
4、检查安装是否成功
mysql --version
5、服务初始化工作
(1)、为了保证数据库目录与文件的所有者为 mysql 登录用户,如果你是以 root 身份运行 mysql 服务,需要执行下面的命令初始化:
mysqld --initialize --user=mysql
(2)、查看密码:
cat /var/log/mysqld.log
(3)、启动、停止、重启、查看状态
启动:systemctl start mysqld
关闭:systemctl stop mysqld
重启:systemctl restart mysqld
查看状态:systemctl status mysqld
(4)、设置开机自启
查看是否开机自启
systemctl list-unit-files|grep mysqld.service
enable表示开机自启,disable表示开击不自启
设置开机自启:
systemctl enable mysqld.service
关闭开机自启:
systemctl disable mysqld.service
三、登录
首次登陆:
mysql -uroot -p
首次登陆后修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
四、Navicat 远程连接
1、关闭Linux的防火墙
2、设置MySQL允许root用户远程连接
use mysql;
update user set host = '%' where user ='root';
3、进入MySQL执行如下命令
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
标签:8.0,31,community,CentOS7,MySQL8.0,版本,mysql,64,el7 From: https://www.cnblogs.com/A121/p/17230869.html