Maria Db 10.1用于远程访问的用户无法正常工作

时间:2016-04-01 07:18:26

标签: mysql mariadb

在使用MariaDB 10.1的服务器上添加具有授予权限的用户,以便远程访问无法正常工作。

步骤。

GRANT ALL PRIVILEGES ON *.* TO 'XXXXXX'@'%' IDENTIFIED BY 'WWWWWWWWW' WITH GRANT OPTION;
FLUSH PRIVILEGES;

验证

SELECT * from information_schema.user_privileges where grantee like "'xxxxxxx'%";
+----------------+---------------+-------------------------+--------------+
| GRANTEE        | TABLE_CATALOG | PRIVILEGE_TYPE          | IS_GRANTABLE |
+----------------+---------------+-------------------------+--------------+
| 'xxxxxxx'@'%' | def           | SELECT                  | YES          |
| 'xxxxxxx'@'%' | def           | INSERT                  | YES          |
| 'xxxxxxx'@'%' | def           | UPDATE                  | YES          |
| 'xxxxxxx'@'%' | def           | DELETE                  | YES          |
| 'xxxxxxx'@'%' | def           | CREATE                  | YES          |
| 'xxxxxxx'@'%' | def           | DROP                    | YES          |
| 'xxxxxxx'@'%' | def           | RELOAD                  | YES          |
| 'xxxxxxx'@'%' | def           | SHUTDOWN                | YES          |
| 'xxxxxxx'@'%' | def           | PROCESS                 | YES          |
| 'xxxxxxx'@'%' | def           | FILE                    | YES          |
| 'xxxxxxx'@'%' | def           | REFERENCES              | YES          |
| 'xxxxxxx'@'%' | def           | INDEX                   | YES          |
| 'xxxxxxx'@'%' | def           | ALTER                   | YES          |
| 'xxxxxxx'@'%' | def           | SHOW DATABASES          | YES          |
| 'xxxxxxx'@'%' | def           | SUPER                   | YES          |
| 'xxxxxxx'@'%' | def           | CREATE TEMPORARY TABLES | YES          |
| 'xxxxxxx'@'%' | def           | LOCK TABLES             | YES          |
| 'xxxxxxx'@'%' | def           | EXECUTE                 | YES          |
| 'xxxxxxx'@'%' | def           | REPLICATION SLAVE       | YES          |
| 'xxxxxxx'@'%' | def           | REPLICATION CLIENT      | YES          |
| 'xxxxxxx'@'%' | def           | CREATE VIEW             | YES          |
| 'xxxxxxx'@'%' | def           | SHOW VIEW               | YES          |
| 'xxxxxxx'@'%' | def           | CREATE ROUTINE          | YES          |
| 'xxxxxxx'@'%' | def           | ALTER ROUTINE           | YES          |
| 'xxxxxxx'@'%' | def           | CREATE USER             | YES          |
| 'xxxxxxx'@'%' | def           | EVENT                   | YES          |
| 'xxxxxxx'@'%' | def           | TRIGGER                 | YES          |
| 'xxxxxxx'@'%' | def           | CREATE TABLESPACE       | YES          |
+----------------+---------------+-------------------------+--------------+
28 rows in set (0.01 sec)

但是当尝试访问其他主机时

mysql -u xxxxxx -h 178.33.XXX.XXX -p
Enter password:
ERROR 1130 (HY000): Host '88.14.189.149' is not allowed to connect to this MariaDB server

也试试

telnet 178.33.XXX.XXX 3306
Trying 178.33.XXX.XXX...
Connected to kvm401.tamainut.net.
Escape character is '^]'.
HHost '88.14.189.149' is not allowed to connect to this MariaDB serverConnection closed by foreign host.

新格式的验证密码

MariaDB [(none)]> select User,Host,password from mysql.user where user LIKE '%xxxxx%' ;
+----------------+--------------------+-------------------------------------------+
| User           | Host               | password                                  |
+----------------+--------------------+-------------------------------------------+
| setdart_xxxxx | domain.tld          | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX       | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | kvm401.domain.tld   | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX       | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX       | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX       | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX       | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX       | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX7      | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX       | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | mysql.domain.tld    | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | XX.XXX.XXX.XX       | *E6B7483F265D61567967300758B7872E03110534 |
| setdart_xxxxx | localhost           | *E6B7483F265D61567967300758B7872E03110534 |
+----------------+--------------------+-------------------------------------------+
13 rows in set (0.00 sec)

为什么不工作?

2 个答案:

答案 0 :(得分:0)

检查sql_acl.cc的来源后,只会想到的是

FLUSH PRIVILEGES;
FLUSH HOSTS;

这可能有助于连接客户端的IP之前有很多ACL错误。

答案 1 :(得分:-2)

您还必须配置服务器以进行远程连接(my.conf)。标准配置会跳过网络,因此您只能通过localhost进行连接。否则,如果存在用户权限问题,您还将获得另一个例外,例如拒绝访问。如果您不知道配置文件的位置,请查看mariadb,因为它取决于您的操作系统。

你必须注释掉(以哈希(#)字符开头)以下几行:

    [mysqld]
    ...
    #skip-networking
    ...
    #bind-address = <some ip-address>
像那样。好吧,如果你必须使用多个接口,你也可以将绑定地址设置为0.0.0.0,但这也是mariadb的标准建议。之后,您必须重新启动服务器,它才能正常工作。