CentOS8 安装 Mysql8 教程

Mysql8安装教程

操作系统版本:CentOS Linux release 8.3
Mysql版本:Mysql 8.0.22 x86_64 (MySQL Community Server - GPL)
Mysql8下载地址:https://dev.mysql.com/downloads/mysql/
我是把如下这几个包下载之后打包到mysql_8_rpm.zip了

1.删除预置安装或文件

rpm -aq | grep mysql | xargs rpm -e --nodeps
rpm -aq | grep mariadb | xargs rpm -e --nodeps
rm -rf `find / -name mysql`

2.rz上传mysql_8_rpm.zip到CentOS8任意目录(我是解压到根目录下的zero目录)

3.解压mysql_8_rpm.zip并进入到解压后的目录,有如下包

4.依次执行以下命令安装rpm包

rpm -ivh mysql-community-common-8.0.22-1.el8.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-libs-8.0.22-1.el8.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-client-8.0.22-1.el8.x86_64.rpm --force --nodeps
rpm -ivh mysql-community-server-8.0.22-1.el8.x86_64.rpm --force --nodeps

5.检查是否全部安装成功

rpm -aq | grep mysql

6.初始化mysql、生成随机密码(用于第一次安全设置)

mysqld --initialize

7.改变属主

chown -R mysql:mysql /var/lib/mysql/

8.启动mysql

systemctl start mysqld

9.查看第一次生成的随机密码

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

10. Mysql安全设置

mysql_secure_installation

完成Mysql8在CentOS8的安装!!!

### 补充指令
# 启动数据库
systemctl start mysqld
# 关闭数据库
systemctl stop mysqld
# 重启数据库
systemctl restart mysqld
# 查看数据库状态
systemctl status mysqld
# 进入mysql
mysql -u root -p'密码'
### 授予远程连接权限
create user 'root'@'%' identified by '123456';
grant all on *.* to `root`@`%` WITH GRANT OPTION;
ALTER USER 'root'@'%' IDENTIFIED with mysql_native_password by '123456';
flush privileges;
posted @ 2021-01-12 00:35  杭州爱软测-zero  阅读(1567)  评论(0编辑  收藏  举报