ERROR 1044 (42000)Access denied for user @localhost to database
2018-01-02 23:56
323 查看
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 -p Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 48 Server 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 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.
设置密码
管理员身份运行
进入安装目录的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 -p Enter password:
登陆成功
C:\Users\admin>mysql -u root -p Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 49
Server 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 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>
建立一个数据库
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)
相关文章推荐
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- Xampp下MariaDB的登陆(ERROR 1044 (42000):Access denied for user ''@'localhost' to database)
- mysql切换数据库时会报错:ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql'
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- mysql报错:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'ych'解决方式
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql'
- ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'test'
- ERROR 1044 (42000):Access denied for user ''@'localhost' to database 'mysql'的解决方法
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- mysql 用命令操作mysql是报错ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'wang'
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- mysql:ERROR 1044(42000):Access denied for user ''@'localhost' to database '***'的解决办法。