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正文
1. 成績描寫:
在MySQL掌握台下創立數據庫湧現以下信息:
mysql> CREATE DATABASE python;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'python'
2. 處理辦法:
履行以下敕令進入掌握台:
mysql --user=root -p
輸出root用戶的暗碼便可進入mysql掌握台:
創立數據庫:
create database python;
顯示一切數據庫:
show databases;
以下:
www.linuxidc.com @www.linuxidc.com:~$ mysql --user=root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2014,Oracleand/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> create database python;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| python |
| test |
+--------------------+
5 rows in set (0.02 sec)
mysql>
3. OK, 以上辦法不是最好的, 但倒是簡略可行的,Enjoy it!!!
4、辦法四:
這幾天用空暗碼登錄mysql後,然後修正mysql默許暗碼,應用mysql表湧現過這個成績,提醒:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'。網上找了一些辦法,終究弄定了。
我用的是xampp集成的mysql,之前空暗碼能登出來phpmyadmin,但怎樣也進不去phpmyadmin的體系表
後來處理勝利發明是由於mysql數據庫的user內外,存在用戶名為空的賬戶即匿名賬戶,招致登錄的時刻是固然用的是root,但現實是匿名登錄的,經由過程毛病提醒裡的''@'localhost'可以看出來。我用辦法一處理了成績,
辦法一:
在my.ini的[mysqld]字段參加:
skip-grant-tables
重啟mysql辦事,這時候的mysql不須要暗碼便可登錄數據庫
然落後入mysql
mysql>use mysql;
mysql>update user set password=password('新暗碼') WHERE User='root';
mysql>flush privileges;
運轉以後最初去失落my.ini中的skip-grant-tables,重啟mysqld便可。
修正mysql暗碼辦法二:
不應用修正my.ini重啟辦事的辦法,經由過程非辦事方法加skip-grant-tables運轉mysql來修正mysql暗碼
停滯mysql辦事
翻開敕令行窗口,在bin目次下應用mysqld-nt.exe啟動,即在敕令行窗口履行: mysqld-nt --skip-grant-tables
然後別的翻開一個敕令行窗口,登錄mysql,此時無需輸出mysql暗碼便可進入。
按以上辦法修正好暗碼後,封閉敕令交運行mysql的誰人窗口,此時即封閉了mysql,假如發明mysql仍在運轉的話可以停止失落對應過程來封閉。
啟動mysql辦事。
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