CentOS 安装Mysql8

1.检查是否已经安装mysql,停止mysql服务,删除mysql

ps -ef | grep -i mysql
systemctl stop mysqld
rpm -e mysql

2.配置仓库

 更新秘钥

rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

 安装mysql8的yum源

rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm

3. 安装mysql

yum -y install mysql-community-server

  启动mysql服务  

// 启动
systemctl start mysqld
//开机自动启动
systemctl enable mysqld
//查看mysql状态
systemctl status mysqld

4. 启动后配置

   初始化mysql密码

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

效果如下图:  CentOS 安装Mysql8_第1张图片

 登录mysql数据库系统
 mysql -uroot -p

修改root初始密码

alter user 'root'@'%' identified by 'abc@123';

5.设置允许远程连接

8.0 之前

grant all privileges on *.* to 'root'@'%'  identified by 'abc@123' with grant option;

8.0之后,需要将创建用户和赋权限分开

create user 'root'@'%' identified by 'abc@123';
grant all privileges on *.* to 'root'@'%'  with grant option;

FLUSH PRIVILEGES; 最后记得要刷新一下缓存

你可能感兴趣的:(linux,centos,linux,运维)