mysql / mariadb:拒绝访问

时间:2018-02-05 13:54:19

标签: mysql

我上周才安装了Debian 9并安装了发行版附带的MySQL:

# mysql                                        
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

所以 - 我可以毫无问题地连接。但是,我根本无法通过TCP连接(不用担心密码,它只是一个演示版):

# mysql -h127.0.0.1 -uroot -pAtauseq01         
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

如果我创建一个新用户,也会发生同样的情况:

# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create user 'jan'@'localhost' identified by 'Atauseq01';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant usage on *.* to 'jan'@'localhost';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on *.* to 'jan'@'localhost' with grant option;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> Bye
# mysql -h127.0.0.1 -ujan@localhost -pAtauseq01
ERROR 1045 (28000): Access denied for user 'jan@localhost'@'localhost' (using password: YES)

我更改了绑定地址:

bind-address            = 0.0.0.0

netstat -nap显示MySQL在0.0.0.0:3306上收听。不幸的是,日志没有显示细节; mysqld的错误日志根本没有显示任何内容,各种客户端告诉我的只是“拒绝访问”。此外,telnet localhost 3306实际上获得了连接,所以我知道我到目前为止,至少。

有没有办法让MySQL日志显示更多细节?

1 个答案:

答案 0 :(得分:0)

我已经决定“回答”我自己的问题-答案确实是由于评论中的aynber引起的,但是我想他太谦虚了,无法将其发布为答案:

  

不要在命令行上使用@localhost。使用mysql -h127.0.0.1 -ujan   -pAtauseq01代替

另外,请参阅Huseyin的评论。