无法登录到mysql新用户?

时间:2018-08-11 07:51:03

标签: mysql root

最近下载并开始使用mysql。我希望它设置正确,并且我的 root用户也登录。 mysql服务也在运行。

我运行了以下几行来创建数据库和新用户,但是我无法登录到新用户。请帮忙。我不知道我在做什么错。

我已经在网上搜索解决方案,但是对于应该遵循的正确步骤感到困惑。

谢谢 :)

PS C:\Users\Akhil> mysql -u root -p;
Enter password: *****

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 5.6.41-log MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mytestdb           |
| performance_schema |
| sakila             |
| test               |
| world              |
+--------------------+
7 rows in set (0.00 sec)

mysql> use mytestdb
Database changed

mysql> create user myuser identified by 'mypass';
ERROR 1396 (HY000): Operation CREATE USER failed for 'myuser'@'%'

mysql> DROP USER myuser;
Query OK, 0 rows affected (0.00 sec)

mysql> create user myuser identified by 'mypass';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON mytestdb.* TO myuser;
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
PS C:\Users\Akhil> mysql -u myuser -p
Enter password: ******
ERROR 1045 (28000): Access denied for user 'myuser'@'localhost' (using password: YES)

PS C:\Users\Akhil>

我为什么无法访问被拒绝...帮助?

1 个答案:

答案 0 :(得分:1)

我已经解决了错误。我所做的是以root用户身份登录。然后键入以下命令:-

DROP USER ''@localhost ;

然后它像一种魅力一样工作!

相关问题