美文网首页
Mysql 3306端口无法被远程机器访问

Mysql 3306端口无法被远程机器访问

作者: DallYu | 来源:发表于2020-10-08 21:23 被阅读0次

    今天尝试从linux下安装Mysql数据库,需要远程测试时发现3306端口无法被远程机器访问。一开始以为是linux防火墙对于3306端口做了限制,但是关闭防火墙后发现也无法进行telnet。
    经查询相关资料发现,mysql默认对于本地连接做了绑定,如果需要远程机器访问,则需要修改相关规则
    具体如下

    1.找到如下文件

    /etc/mysql/mysql.conf.d/mysqld.cnf
    

    2.打开该文件,显示

    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License, version 2.0, for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program; if not, write to the Free Software
    # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
    
    #
    # The MySQL  Server configuration file.
    #
    # For explanations see
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
    
    [mysqld]
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    datadir         = /var/lib/mysql
    log-error       = /var/log/mysql/error.log
    # By default we only accept connections from localhost
    bind-address  = 127.0.0.1
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    

    3.找到 bind-address 项
    注释该项或者添加指定访问远程机

    # bind-address  = 127.0.0.1
    bind-address=127.0.0.1  xx.xx.xx.xx
    

    相关文章

      网友评论

          本文标题:Mysql 3306端口无法被远程机器访问

          本文链接:https://www.haomeiwen.com/subject/qhahpktx.html