zoukankan      html  css  js  c++  java
  • ubuntu上mysql服务器安装后只能本地连接不能远程连接的问题

    安装好mysql后,想使用另一个电脑进行远程登录,在登录时 提示拒绝连接

    百度后,发现需要两个步骤解决该问题

    • /etc/mysql/my.cnf 里修改bind_address = 0.0.0.0 
    •  进行授权

     (1)直接授权

    mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
    mysql>FLUSH RIVILEGES;

      (2)改表法 可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改成”%”

    mysql -u root -p passwd 
    mysql>use mysql;
    mysql>update user set host = '%' where user = 'root';
    mysql>select host, user from user;
    但是在进行第一步的时候,my.cnf里的内容却是如下这样的:
    #
    
    # The MySQL database server configuration file.
    
    #
    
    # You can copy this to one of:
    
    # - "/etc/mysql/my.cnf" to set global options,
    
    # - "~/.my.cnf" to set user-specific options.
    
    # 
    
    # One can use all long options that the program supports.
    
    # Run program with --help to get a list of available options and with
    
    # --print-defaults to see which it would actually understand and use.
    
    #
    
    # For explanations see
    
    # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
    
     
    
    #
    
    # * IMPORTANT: Additional settings that can override those from this file!
    
    #   The files must end with '.cnf', otherwise they'll be ignored.
    
    #
    
    
    !includedir /etc/mysql/conf.d/
    
    !includedir /etc/mysql/mysql.conf.d/
    

     最后发现,需要修改 的是  /etc/mysql/mysql.conf.d/mysqld.cnf

       使用sudovim /etc/mysql/mysql.conf.d/mysqld.cnf

       修改bind_address = 0.0.0.0 

       然后重启mysql服务即可: sudo /etc/init.d/mysql restart

  • 相关阅读:
    第四次博客作业-结对项目
    软件工程第三次作业——关于软件质量保障初探
    java 自动生成四则运算式
    《构建之法》第一章学习笔记
    给大家分享一个小程序—2048
    Java异常处理认识
    轻松定位CPU飙高问题
    接手​「烂摊子」,管理者怎么办?
    业务中台建设篇
    互联网巨头“大中台,小前台”战略
  • 原文地址:https://www.cnblogs.com/ld-swust/p/5986279.html
Copyright © 2011-2022 走看看