【软件安装记录篇】本地虚拟机Centos7快速安装MySQL

安装

采用Installing MySQL on Linux Using the MySQL Yum Repository的方式进行安装。
1. 首先下载服务器版本对应的rpm文件,下载地址:链接,下载完成之后上传到自己的某个文件夹中。

2. 安装rpm文件:sudo yum install mysql80-community-release-el7-{version-number}.noarch.rpm;

3. 安装社区版数据库:yum install mysql-community-server;

4. 启动Mysql:service mysqld restart;

修改密码

1. 查看初始化密码:grep 'temporary password' /var/log/mysqld.log;,这个log中记录着初始化密码。

2. 用初始化密码进行登入到MySQL:mysql -uroot -p;。

3. 设置修改之后的密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'kdaDDy123!';注意此处的密码设置有所要求,必须是数字外加大小写外加特殊字符组成,否则会报设置失败Your password does not satisfy the current policy requirements。

远程连接

1. 创建远程连接的用户:create user 'ktdaddy'@'%' identified with mysql_native_password by '1eeLjihao!';

2. 授权远程用户:grant all on . to 'ktdaddy' @'%';

3. 刷新权限:flush privileges;

4. 尝试用远程工具测试连接。登录名为ktdaddy,密码为:1eeLjihao!。如果此时发现依旧无法连接,那么要考虑是否是防火墙没有关闭。

5. 输入命令systemctl status firewalld.service;,如果发现防火墙为active(running),那么此时防火墙为打开状态。此时关闭防火墙。

6. 临时关闭防火墙systemctl stop firewalld.service;,然后可以用命令systemctl status firewalld.service检查防火墙的状态。

7. 若要永久关闭防火墙systemctl disable firewalld.service;。

8. 再次测试连接数据库,则连接成功!

posted @ 2021-01-20 23:30  程序员老猫  阅读(240)  评论(0)    收藏  举报