centos8 yum方式安装mysql8

采用yum安装,可以简化安装步骤。在没有特殊需求的情况下,该安装方式是合适的。

1.  获取官方下载地址

https://dev.mysql.com/downloads/repo/yum/

2. 下载文件

wget https://repo.mysql.com/mysql80-community-release-el8-3.noarch.rpm

3. 执行安装

# yum localinstall mysql80-community-release-el8-3.noarch.rpm

4. 查看yum源

# yum repolist enabled | grep "mysql.-community*"
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration

5. 禁用centos8.0自带的mysql模块

yum module disable mysql

6. 安装mysql

yum install mysql-community-server

7. 修改默认配置

vim /etc/my.cnf

设置大小写不敏感。 如果有端口冲突,可以设置单独的端口。密码加密算法插件。

相关参数配置项根据需要添加。

#让MYSQL大小写敏感(1-不敏感,0-敏感)
lower_case_table_names=1

port=13306

default_authentication_plugin=mysql_native_password

8. 启动mysql服务

systemctl start mysqld

查看mysql服务启动状态

systemctl status mysqld

9.  查看mysql安装时生成的随机密码

grep ‘temporary password’ /var/log/mysqld.log

10. 登录mysql

mysql -uroot -p

输入临时密码。

11. 修改登录密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

12. 开放mysql远程访问

# 创建权限记录:
mysql> CREATE user 'root'@'%' IDENTIFIED BY '您的密码';

# 授权:
mysql> GRANT ALL PRIVILEGES ON . TO 'root' @'%' WITH GRANT OPTION;

# 修改密码过期策略:
mysql> ALTER USER 'root' @'localhost' IDENTIFIED BY '您的密码' PASSWORD EXPIRE NEVER;

# 重新修改密码:
mysql> ALTER USER 'root' @'%' IDENTIFIED WITH mysql_native_password BY '您的密码';

# 刷新权限:
mysql> FLUSH PRIVILEGES;
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值