在centos虛擬機中添加遠程Myql鏈接問題總結

一:安裝myql方式:mysql

CentOS 7的yum源中貌似沒有正常安裝mysql時的mysql-sever文件,須要去官網上下載sql

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
成功安裝以後重啓mysql服務
# service mysqld restart
 

二:安裝完成以後遠程mysql服務器遇到的問題解決方法centos

1:vi /etc/my.cnf文件我在本機上撞了一個centos7虛擬機,而後安裝了社區版的mysql,開始老遠程鏈接不到此mysql服務器安全

修改my.cnf使mysql監聽在任意ip地址服務器

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 0.0.0.0less

2:tcp

 

解決辦法:安全模式修改root密碼ui

 

#> service mysqld stop
       #>mysqld_safe --skip-grant-tables &
       輸入 mysql -uroot -p 回車進入
       >use mysql;
       > update user set password=PASSWORD("123456")where user="root";
       更改密碼爲 newpassord
       > flush privileges; 更新權限
       > quit 退出this

 

service mysqld restart
       mysql -uroot -p 新密碼進入centos7

3:放開3306端口防火牆在文件  vi /etc/sysconfig/iptables

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

這是本人在虛擬機上安裝mysql遇到的問題

相關文章
相關標籤/搜索