mysql新建用户在本地无法登录

来源:互联网 发布:地图龟淘宝哪家的好 编辑:程序博客网 时间:2024/05/24 00:33

新建了一个mysql用户,但是无法在本地登录,即使已经授权任一ip都可以登录,甚至特地写清楚localhost登录,还是不行,情况如下

[root@localhost zabbix-release-3.2]# mysql -ubiaopei -pEnter password: ERROR 1045 (28000): Access denied for user 'biaopei'@'localhost' (using password: YES)                  #输入密码报错,但是在其他电脑上输入这个密码后可以正常登录

网上的解决方法乱七八糟的,以后有空再慢慢研究吧。我的解决方法是,不输入密码,直接回车
情况如下

[root@localhost zabbix-release-3.2]# mysql -ubiaopei -pEnter password:                         #不输密码可以正常登录Welcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 64Server version: 5.5.52-MariaDB MariaDB ServerCopyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]> 

后来也发现,直接回车也不行,需要把允许ip范围改成下面的样子即%才可以

MariaDB [(none)]> select user,host from mysql.user;+---------+-------------+| user    | host        |+---------+-------------+| biaopei | %           |       #运行所有ip地址登录| root    | 127.0.0.1   || biaopei | 192.168.2.% || root    | ::1         || root    | localhost   |+---------+-------------+5 rows in set (0.00 sec)MariaDB [(none)]> 
原创粉丝点击