采用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;
|