我最近下载并开始使用 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>
为什么我的访问被拒绝,我无法理解...帮助?
最佳答案
我已经解决了这个错误。我所做的是使用root用户登录。然后输入以下命令:-
删除用户''@localhost;
然后它就像一个魅力!
关于mysql - mysql新用户无法登录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51797651/