mysql ERROR 1044 (42000): Access denied for user ~~@~localhost~ to database |
1. 问题描述: 在MySQL控制台下创建数据库出现以下信息: mysql> CREATE DATABASE python; 2. 解决方法: 执行以下命令进入控制台: mysql --user=root -p 输入root用户的密码即可进入mysql控制台: 创建数据库: create database python; 显示所有数据库: show databases; 如下: www.linuxidc.com @www.linuxidc.com:'$ mysql --user=root -p Copyright (c) 2000, 2014,Oracleand/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its Type help; or \h for help. Type \c to clear the current input statement. mysql> create database python; mysql> show databases; mysql> 3. OK, 以上方法不是最好的, 但却是简单可行的,Enjoy it!!! 4、方法四: 这几天用空密码登录mysql后,然后修改mysql默认密码,使用mysql表出现过这个问题,提示:ERROR 1044 (42000): Access denied for user @localhost to database mysql 。网上找了一些方法,终于搞定了 。 我用的是xampp集成的mysql,之前空密码能登进去phpmyadmin,但怎么也进不去phpmyadmin的系统表 skip-grant-tables 重启mysql服务,这时的mysql不需要密码即可登录数据库 mysql>use mysql; 运行之后最后去掉my.ini中的skip-grant-tables,重启mysqld即可 。 linux下的处理方法: mysql> use mysql ERROR 1044 (42000): Access denied for user root@localhost to database mysql mysql> exit Bye [root@testtest ']# service mysqld stop Stopping mysqld: [ OK ] [root@testtest ']# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & [root@testtest ']# mysql -u root -p -hlocalhost Enter password: mysql> use mysql mysql> SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user; mysql> UPDATE mysql.user SET Grant_priv=Y, Super_priv=Y WHERE User=root; mysql> FLUSH PRIVILEGES; mysql> GRANT ALL ON *.* TO root@localhost; mysql> GRANT ALL ON *.* TO root@cn.cn.cn.cn; mysql> GRANT ALL ON *.* TO root@245.245.245.245; mysql> GRANT ALL ON *.* TO root@127.0.0.1; mysql> FLUSH PRIVILEGES; mysql> quit Bye [root@testtest ']# service mysqld start restart Linux/OS |