• 开启Mysql远程访问的所有方法


    开启Mysql远程访问的所有方法  

    http://superyjcqw.blog.163.com/blog/static/16105830520117111040436/

    Mysql默认是不可以通过远程机器访问的,通过下面的配置可以开启远程访问.
    其实就是两个办法,最终都是为了修改 user 表中 root 对应的 host 字段为 %
    1. update user set host=’%’ where user=’root’;
    flush privileges;
    这种方法不用理会root的密码,经过实际测试,有些情况下执行这条语句会报下面的错误:

    ERROR 1062 (23000): Duplicate entry ‘%-root’ for key ‘PRIMARY’

    改成这样的就可以执行了

    update user set host=’%’ where user=’root’ and host=’localhost’;

    也就是把localhost改成了所有主机
    2. grant all on *.* to 
    root@’%’ identified by ‘123456′;

    *.* 指定给了所有数据库了。

    3.修改/etc/mysql/my.conf,修改bind-address,指定为本机实际IP地址,你的my.con修改完大概是如下的样子

    [mysqld]
    #
    # * Basic Settings
    #
    default-character-set=utf8
    default-storage-engine=INNODBuser            = mysql
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    port            = 3306
    basedir         = /usr
    datadir         = /var/lib/mysql
    tmpdir          = /tmp
    language        = /usr/share/mysql/english
    skip-external-lockinggrant all on sonardb.* to 
    sonar@’%’ identified by ‘123456′;
    grant all on sonardb.* to 
    sonar@localhost identified by ‘123456′;
    sonardb替换为你想访问的数据库名,sonar是你的想使用的用户名,123456替换为你的密码,这样就开启了远程访问功能.

    bind-address    = 192.168.1.107

    4、用root登陆mysql执行如下命令
    grant all on sonardb.* to 
    sonar@’%’ identified by ‘123456′;
    grant all on sonardb.* to 
    sonar@localhost identified by ‘123456′;
    sonardb替换为你想访问的数据库名,sonar是你的想使用的用户名,123456替换为你的密码,这样就开启了远程访问功能.

  • 相关阅读:
    Ajax核心对象和AjaxPro框架
    ASP.NET XML与JSON
    jQuery中Ajax的应用
    jQuery中操作表单与表格
    IOS 非常流畅的滑动tableView
    提高自己应用性能的总结架构篇
    LazyCode 自己开源的一个类库
    iOS 自己写的对话框中加入三个输入框
    icmp 流量抓取 转发 代理(2)
    sublime text ctags插件使用
  • 原文地址:https://www.cnblogs.com/patf/p/3375934.html
Copyright © 2020-2023  润新知