zoukankan      html  css  js  c++  java
  • Ubuntu 14.10 下MySQL无法远程连接问题

    安装好MySQL之后,如果需要远程连接,那么需要做一些配置,否则会出现一些类似的错误,如

     mysql root用户ERROR 1045 (28000):
     mysql 远程登录 ERROR 1045 (28000)
     mysql 远程登录2003
    Can not connect to mysql error 10061

    1 当MySQL 连接服务器时发生”Can not connect to mysql error 10061”错误

      将/etc/mysql/my.conf文件中的bind-address选项设置为MySQL服务器的IP,默认为127.0.0.1。

      然后sudo /etc/init.d/mysql restart  --重启服务

    2 当MySQL 连接服务器时发生”is not allowed to connect to this MySQL server”错误

      将MySQL数据库中的user表中的host列的localhost为%

    delete from user where user='root' and host <> '%';  -- 删除多余用户
    update user set host ='%' where host='localhost' and user='root';  --更新host
    select host,user,password from user;
    +-----------+------------------+-------------------------------------------+
    | host      | user             | password                                  |
    +-----------+------------------+-------------------------------------------+
    | localhost | debian-sys-maint | *3B3724AE1051D0628525347DAC3635A6C523F944 |
    | %         | root             | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
    | %         | hive             | *4DF1D66463C18D44E3B001A8FB1BBFBEA13E27FC |
    +-----------+------------------+-------------------------------------------+

    3 此时没有127.0.0.1和localhost主机,所以无法用root用户进行连接,会提示以下错误

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

       则此时只能用系统自带的debian-sys-maint用户登录,给root用户赋予新的权限。debian-sys-maint用户的的登录密码在/etc/mysql/debian.cnf中明文显示。

     grant all on *.* to root@'%' identified by 'user_password';

    4 如果不想root用户被远程登录,可以新建用户

    mysql -u root -p
    insert into user(Host,User,Password) values("%","hive",password("hive"));
    FLUSH PRIVILEGES;
    
    
    GRANT ALL PRIVILEGES ON *.*  TO 'hive'@'%' IDENTIFIED BY 'hive';
    FLUSH PRIVILEGES;
  • 相关阅读:
    纯CSS星级评价
    Enterprise Library启用签名后发生 PublicKeyToken错误,HRESULT:0x80131040解决
    SQL Server
    该如何选择国外VPS
    网站的伪静态化
    kernel FIELD_SIZEOF宏 NULL地址不访问不出错
    Activity的四种加载模式
    Git magic 简短git使用命令集
    为什么包含多句代码的宏要用do while包括起来?
    使用lsof来查看FD和进程的关系
  • 原文地址:https://www.cnblogs.com/liuchangchun/p/4431426.html
Copyright © 2011-2022 走看看