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
效果如下图:
登录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;文章来源:https://www.toymoban.com/news/detail-606906.html
FLUSH PRIVILEGES; 最后记得要刷新一下缓存文章来源地址https://www.toymoban.com/news/detail-606906.html
到了这里,关于CentOS 安装Mysql8的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!