国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

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

2020-01-18 22:46:10
字體:
供稿:網(wǎng)友

1. 問題描述:

在MySQL控制臺下創(chuàng)建數(shù)據(jù)庫出現(xiàn)以下信息:

mysql> CREATE DATABASE python;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'python'

2. 解決方法:

執(zhí)行以下命令進(jìn)入控制臺:

mysql --user=root -p

輸入root用戶的密碼即可進(jìn)入mysql控制臺:

創(chuàng)建數(shù)據(jù)庫:

create database python;

顯示所有數(shù)據(jù)庫:

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默認(rèn)密碼,使用mysql表出現(xiàn)過這個問題,提示:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'。網(wǎng)上找了一些方法,終于搞定了。

我用的是xampp集成的mysql,之前空密碼能登進(jìn)去phpmyadmin,但怎么也進(jìn)不去phpmyadmin的系統(tǒng)表

后來解決成功發(fā)現(xiàn)是因為mysql數(shù)據(jù)庫的user表里,存在用戶名為空的賬戶即匿名賬戶,導(dǎo)致登錄的時候是雖然用的是root,但實際是匿名登錄的,通過錯誤提示里的''@'localhost'可以看出來。我用方法一解決了問題,

方法一:
在my.ini的[mysqld]字段加入:

skip-grant-tables

重啟mysql服務(wù),這時的mysql不需要密碼即可登錄數(shù)據(jù)庫
然后進(jìn)入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重啟服務(wù)的方法,通過非服務(wù)方式加skip-grant-tables運行mysql來修改mysql密碼
停止mysql服務(wù)
打開命令行窗口,在bin目錄下使用mysqld-nt.exe啟動,即在命令行窗口執(zhí)行: mysqld-nt --skip-grant-tables
然后另外打開一個命令行窗口,登錄mysql,此時無需輸入mysql密碼即可進(jìn)入。
按以上方法修改好密碼后,關(guān)閉命令行運行mysql的那個窗口,此時即關(guān)閉了mysql,如果發(fā)現(xiàn)mysql仍在運行的話可以結(jié)束掉對應(yīng)進(jìn)程來關(guān)閉。
啟動mysql服務(wù)。

linux下的處理方法:

mysql> use mysqlERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql'mysql> exitBye[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 -hlocalhostEnter password: mysql> use mysqlmysql> 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> quitBye[root@testtest ~]# service mysqld start restart Linux/OS 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 兴仁县| 若羌县| 合肥市| 黄陵县| 邛崃市| 原平市| 同仁县| 西充县| 洞口县| 类乌齐县| 沁阳市| 乳源| 黄浦区| 尤溪县| 集贤县| 闽清县| 民县| 阿拉善盟| 拉萨市| 鲁甸县| 海伦市| 清丰县| 宣汉县| 灵武市| 南靖县| 永嘉县| 富宁县| 来宾市| 安康市| 凤冈县| 威信县| 濮阳市| 五大连池市| 舒兰市| 杭锦旗| 伊宁市| 建平县| 清远市| 习水县| 开江县| 岳阳县|