微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Centos7 安装mysql服务器并开启远程访问功能

华为云服务器 Centos7 安装MysqL服务器并开启远程访问功能,过程记录

安装 (以root身份操作):

1.   yum -y install weget

2. wget -i -c http://dev.MysqL.com/get/MysqL57-community-release-el7-10.noarch.rpm

3. yum -y install MysqL57-community-release-el7-10.noarch.rpm

使用yum -y install MysqL-community-server安装MysqL时候提示
The GPG keys listed for the “MysqL 5.7 Community Server” repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.

Failing package is: MysqL-community-libs-compat-5.7.37-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-MysqL
原因是MysqL的GPG升级了,需要重新获取

4. rpm --import https://repo.MysqL.com/RPM-GPG-KEY-MysqL-2022

 

5.yum install MysqL-server

 

配置

6.    systemctl start MysqLd.service

7.    systemctl status MysqLd.service

8.    grep "password" /var/log/MysqLd.log

9.    MysqL -uroot -p

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

其中‘new password’替换成你要设置的密码,注意:密码设置必须要大小写字母数字和特殊符号(,/';:等),不然不能配置成功

 

远程访问

11.    grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;

12.  flush privileges;

13.     exit

 

其他配置

14.     systemctl start firewalld

     firewall-cmd --zone=public --add-port=3306/tcp --permanent
     firewall-cmd --zone=public --add-port=8080/tcp --permanent
     firewall-cmd --reload

15. 先退出MysqL,然后再到、etc目录下的my.cnf文件修改一下文件内容

   vim /etc/my.cnf

 




参考链接:

    https://blog.csdn.net/searlas/article/details/123393829?spm=1001.2014.3001.5506

   https://blog.csdn.net/qq_36582604/article/details/80526287?spm=1001.2014.3001.5506



 
 

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐