mysql errors函数_Mysql Errors

这个字段是一个比较神奇的字段。该字段有值,则不允许root@localhost 免密码登录,若该字段无值,则不允许 root@localhost 使用密码登录。

这两种情况,与authentication_string字段没有关系。 发现该问题的版本是Mariadb 10.2.25.

下面是验证过程:

# password 字段不为空时,不允许免密登录

[root@tycxaiftest1 ~]# mysql

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

# 使用密码登录,并查看password 的值

[root@tycxaiftest1 ~]# mysql -uroot -hlocalhost -p

Enter password:

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 16

Server version: 10.2.25-MariaDB Source distribution

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

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

MariaDB [(none)]> select password from mysql.user where user='root' and host='localhost';

+-------------------------------------------+

| password |

+-------------------------------------------+

| *5AF624CAC5796884CBBEDD5FF7A02C3BEC52E2B2 |

+-------------------------------------------+

1 row in set (0.00 sec)

# 将该字段设置为空。

MariaDB [(none)]> update mysql.user set password='' where user='root' and host='localhost';

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit

Bye

# 验证: password 字段为允时允许免密登录

[root@tycxaiftest1 ~]# mysql

Welcome to the MariaDB monitor. Commands end with ; or \g.

Your MariaDB connection id is 17

Server version: 10.2.25-MariaDB Source distribution

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

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

MariaDB [(none)]>

# 验证 password 字段为空时,不允许使用密码登录

MariaDB [(none)]> exit

Bye

[root@tycxaiftest1 ~]# mysql -uroot -h localhost -p

Enter password:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值