zoukankan      html  css  js  c++  java
  • centos 7 下安装mysql 远程连接出现10038错误如何解决

    centos7 安装完mysql后想使用远程连接mysql进行管理,但是并没有那么简单 cant connect to mysql server on 10038

    对没错,肯定会出现这样那样的问题,解决方案

    首先 设置远程访问权限 在mysql中执行语句

    grant all privileges on *.*  to  'root'@'%'  identified by 'youpassword'  with grant option;

    *.* 允许远程访问的IP地址 .表示所有IP都可以根据root用户进行访问

    youpassword就是mysql数据库密码

    1.  flush privileges; //刷新MySQL的系统权限相关表­
    2.  quit; // 退出mysql

    记得重启mysql centos7下如何重启?

    service mysql restart #重启mysql命令

    好了,试试可以连接成功吗?结果是否定的,还是不行,怎么办?防火墙,对

    但是centos7的防火墙默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。

    1、关闭firewall:

    1.  systemctl stop firewalld.service #停止firewall
    2.  systemctl disable firewalld.service #禁止firewall开机启动
    3.  firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

    2、iptables防火墙(这里iptables已经安装,下面进行配置,如果没有安装可先安装防火墙)

    1.  #先检查是否安装了iptables
    2.  service iptables status
    3.  #安装iptables
    4.  yum install -y iptables
    5.  #升级iptables(安装的最新版本则不需要)
    6.  yum update iptables
    7.  #安装iptables-services
    8.  yum install iptables-services

    iptables没有问题后执行下面的命令

    vi /etc/sysconfig/iptables #编辑防火墙配置文件

    这时候会进入vi编辑,你会看到里面的配置信息

    # sampleconfiguration for iptables service

    # you can edit thismanually or use system-config-firewall
    1. # please do not askus to add additional ports/services to this default configuration
    2. *filter
    3. :INPUT ACCEPT [0:0]
    4. :FORWARD ACCEPT[0:0]
    5. :OUTPUT ACCEPT[0:0]
    6. -A INPUT -m state--state RELATED,ESTABLISHED -j ACCEPT
    7. -A INPUT -p icmp -jACCEPT
    8. -A INPUT -i lo -jACCEPT
    9. -A INPUT -p tcp -mstate --state NEW -m tcp --dport 22 -j ACCEPT
    10. -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -jACCEPT
    11. -A INPUT -p tcp -m state --state NEW -m tcp --dport 8080-j ACCEPT
    12. -A INPUT -j REJECT--reject-with icmp-host-prohibited
    13. -A FORWARD -jREJECT --reject-with icmp-host-prohibited
    14. COMMIT
       
    15. :wq! #保存退出

    当然,里面的这三行是没有的,把下面的三行配置添加到里面,如果编辑vi不会可以百度,实际上按i就进入编辑模式了,具体操作可以百度

     
    -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
     
    完成后执行下面的命令
    1.  systemctl restart iptables.service #最后重启防火墙使配置生效
    2.  systemctl enable iptables.service #设置防火墙开机启动

    然后再看看,mysql是否已经连接,到这里后我已经成功连接

  • 相关阅读:
    实验-继承&super.doc
    Python库
    Github高级搜索
    代码报错记录
    编程问题解决
    百科
    【Android】添加依赖包
    【Android】导航栏(加图片icon)和不同页面的实现(viewpager+tablayout)
    【Android】Android Studio真机调试的问题统整
    【AD】自己画板的备忘
  • 原文地址:https://www.cnblogs.com/daniel2021/p/10709840.html
Copyright © 2011-2022 走看看