博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ERROR 1044 (42000)Access denied for user @localhost to database
阅读量:4145 次
发布时间:2019-05-25

本文共 2033 字,大约阅读时间需要 6 分钟。

ERROR 1044 (42000): Access denied for user ”@’localhost’ to database ‘demo’

不管输入什么都是提示权限不够

mysql> create database sufadi;ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'sufadi'

原因

默认情况是匿名用户登陆,所以我们需要设置一个密码,然后每次需要登陆以下并进入

D:\python3-webapp-Su\www>mysql -u root -pEnter password: ******Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 48Server version: 5.6.24 MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

设置密码

管理员身份运行

进入安装目录的bin文件,右键选择管理员身份运行mysql.exe

管理员运行

设置密码

UPDATE user SET Password=PASSWORD(‘123456’) WHERE user=’root’;

mysql> UPDATE user SET Password=PASSWORD('123456') WHERE user='root';Query OK, 3 rows affected (0.03 sec)Rows matched: 3  Changed: 3  Warnings: 0

刷新一下

flush privileges;

mysql> flush privileges    -> ;Query OK, 0 rows affected (0.01 sec)

cmd窗口重新登陆一下

mysql -u root -p

输入密码

C:\Users\admin>mysql -u root -pEnter password:

登陆成功

C:\Users\admin>mysql -u root -pEnter password: ******Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 49Server version: 5.6.24 MySQL Community Server (GPL)Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

建立一个数据库

mysql> create database pythondb;Query OK, 1 row affected (0.01 sec)

show databases

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || demo               || mysql              || performance_schema || pythondb           || sufadi             || test               |+--------------------+7 rows in set (0.00 sec)
你可能感兴趣的文章
前阿里手淘前端负责人@winter:前端人如何保持竞争力?
查看>>
【JavaScript 教程】面向对象编程——实例对象与 new 命令
查看>>
我在网易做了6年前端,想给求职者4条建议
查看>>
SQL1015N The database is in an inconsistent state. SQLSTATE=55025
查看>>
RQP-DEF-0177
查看>>
MySQL字段类型的选择与MySQL的查询效率
查看>>
Java的Properties配置文件用法【续】
查看>>
JAVA操作properties文件的代码实例
查看>>
IPS开发手记【一】
查看>>
Java通用字符处理类
查看>>
文件上传时生成“日期+随机数”式文件名前缀的Java代码
查看>>
Java代码检查工具Checkstyle常见输出结果
查看>>
北京十大情人分手圣地
查看>>
Android自动关机代码
查看>>
Android中启动其他Activity并返回结果
查看>>
2009年33所高校被暂停或被限制招生
查看>>
GlassFish 部署及应用入门
查看>>
X-code7 beta error: warning: Is a directory
查看>>
Error: An App ID with identifier "*****" is not avaliable. Please enter a different string.
查看>>
3.5 YOLO9000: Better,Faster,Stronger(YOLO9000:更好,更快,更强)
查看>>