MySql教程

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

本文主要是介绍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


 
 

 

这篇关于Centos7 安装mysql服务器并开启远程访问功能的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!