linux centos7 mysql无法远程连接解决办法
[caibo@localhost /]firewall−cmd–zone=public–add−port=3306/tcp–permanentsuccess[caibo@localhost/]firewall−cmd–zone=public–add−port=3306/tcp–permanentsuccess[caibo@localhost/] firewall-cmd –zone=public
[caibo@localhost /] firewall−cmd–zone=public–add−port=3306/tcp–permanentsuccess[caibo@localhost/] f i r e w a l l − c m d – z o n e = p u b l i c – a d d − p o r t = 3306 / t c p – p e r m a n e n t s u c c e s s [ c a i b o @ l o c a l h o s t / ] firewall-cmd –reload
systemctl stop firewalld.service #停止
systemctl disable firewalld.service #禁用
mysql安装后还要允许远程连接,其他服务器才能连接到本地的数据库。
mysql账户是否不允许远程连接。如果无法连接可以尝试以下方法:
mysql -u root -p //登录MySQL
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION; //任何远程主机都可以访问数据库
mysql> FLUSH PRIVILEGES; //需要输入次命令使修改生效
mysql> EXIT //退出
也可以通过修改表来实现远程:
mysql -u root -p
mysql> use mysql;
mysql> update user set host = '%' where user = 'root';
mysql> select host, user from user;
更多推荐
所有评论(0)