【六】VirtualBox Centos7 安装 MySQL

准备:

  • VirtualBox
  • Centos7
  • MySQL 5.7

1、从 MySQL 官网下载,mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar

tar -xvf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar -C mysql-5.7 # 解压

解压的文件:
在这里插入图片描述
2、 执行命令安装:

yum install mysql-community-{server,client,common,libs}-* mysql-5.*

配置文件在:/etc/my.cnf

3、启动 mysql 服务:

systemctl start mysqld

4、设置 root 密码

mysql -uroot -p 
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'your password'; # 修改root密码

设置密码的时候有可能出现:

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

这是 mysql 密码策略的问题,

show variables like 'validate_password%';  # 查看密码策略
set global validate_password_policy=LOW;   # 修改密码策略

参考:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

5、远程登录
5.1 关闭防火墙
在这里插入图片描述
如果有报上面这个错,执行命令关闭防火墙:

systemctl stop firewalld.service

参考:centOS7永久关闭防火墙(防火墙的基本使用)

5.2 让 MySQL 允许远程登录
继续使用 Navicat Premium 访问出现如下错误:
在这里插入图片描述
登录 mysql 修改配置:

mysql> use mysql
mysql> select host from user where user = 'root';
+-----------+
| host      |
+-----------+
| localhost |
+-----------+
1 row in set (0.00 sec)
mysql> update user set host = '%' where user = 'root';
mysql> FLUSH PRIVILEGES;
mysql>

参考:Host is not allowed to connect to this MySQL server解决方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值