简体   繁体   中英

Maria Db 10.1 User for remote access not work

On server with MariaDB 10.1 add user with grant privileges, for access remotly not work.

Steps.

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

Verify

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)

But when try access form other host

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

also try

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.

VErification password on new format

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)

Why not work?

After checking source of sql_acl.cc only thing which comes to mind is to

FLUSH PRIVILEGES;
FLUSH HOSTS;

This may help for case when connecting client's IP had many ACL errors before.

You have also to configure your server for remote connections (my.conf). The standard configuration skips networking and so you can only connect via localhost. Otherwise you would also get another exception like access denied if there is a user privilege problem. If you do not know where you will find your configuration file, then have a look at mariadb , because it is depending on your OS.

You have to commented out (prefaced with hash (#) characters) the following lines:

    [mysqld]
    ...
    #skip-networking
    ...
    #bind-address = <some ip-address>

like that. okay you could also set the bind address to 0.0.0.0 if you have to use multiple interfaces, but that is also the standard advice at mariadb. After that you have to restart your server and it will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM