CentOS7.3 安装配置MySql8

  1. 安装Mysql
    ① wget https://repo.mysql.com//mysql80-community-release-el7-2.noarch.rpm
    ② sudo rpm -Uvh platform-and-version-specific-package-name.rpm(下载到根目录的安装文件名)
    ③ yum install -y mysql-community-server
    ④ 启动:service mysqld start
    ⑤ 查看状态:service mysqld status
    在这里插入图片描述

  2. 修改临时密码
    ① 查看临时密码:grep ‘temporary password’ /var/log/mysqld.log
    ② 登录mysql:mysql -u root -p
    ③ 修改密码:ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘root123’;(MySql8要求密码复杂度,大小写字母+数字+特殊字符),如果要修改密码策略,使用以下语句:
    mysql> set global validate_password.policy=0;
    mysql> set global validate_password.length=1;

  3. 修改远程连接权限(允许远程主机登录MySql)
    注意: MySQL 安装完成后只支持 localhost 访问,我们必须设置一下才可以远程访问。
    输入以下命令发现均报错:
    mysql> GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘Root123!’ WITH GRANT OPTION;
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IDENTIFIED BY ‘Root123!’ WITH GRANT OPTION’ at line 1
    mysql> GRANT ALL ON . TO ‘root’@’%’;
    ERROR 1410 (42000): You are not allowed to create a user with GRANT
    mysql> grant all privileges on . to ‘root’@’%’ with grant option;
    ERROR 1410 (42000): You are not allowed to create a user with GRANT

① 可执行如下命令修改root远程连接权限:
mysql> update user set host = “%” where user=‘root’;
② 打开3360端口
查看状态:systemctl status firewalld
开启firewalld(如果不是running状态):systemctl start firewalld
开启端口:firewall-cmd --zone=public --add-port=3306/tcp --permanent
重新载入:firewall-cmd --reload
查看:firewall-cmd --zone=public --query-port=3306/tcp
删除端口:firewall-cmd --zone=public --remove-port=3306/tcp --permanent

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值