mysql/mariadb:访问被拒绝 [英] mysql/mariadb: Access denied

查看:223
本文介绍了mysql/mariadb:访问被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have installed Debian 9 only last week and installed the MySQL that comes with the distro:

# 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 连接(不要担心密码,这只是一个演示):

So - I can connect without problems like that. However, I can't connect over TCP at all (don't worry about the password, it is only a demo one):

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

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

The same happens if I create a new user:

# 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 实际上得到了一个连接,所以我知道我至少做到了这一点.

And netstat -nap shows MySQL listening on 0.0.0.0:3306. Unfortunately the logs show no detail; mysqld's error log shows nothing at all, and various client tell me no more than 'access denied'. Also, telnet localhost 3306 actually gets a connection, so I know I get that far, at least.

有什么办法可以让 MySQL 日志显示更多细节吗?

Is there any way to get the MySQL log to show more detail?

推荐答案

我决定回答"我自己的问题 - 实际上答案是由于评论中的 aynber,但我猜他太谦虚了,无法发布作为答案:

I've decided to "answer" my own question - really the answer is due to aynber in the comments, but I guess he was too modest to post it as an answer:

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

Don't use @localhost on your commandline. Use mysql -h127.0.0.1 -ujan -pAtauseq01 instead

另请参阅 Huseyin 的评论.

Also, see the comment by Huseyin.

这篇关于mysql/mariadb:访问被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆