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

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

mysql ERROR 1044 (42000): Access denied for user ''@'localho

2024-07-24 12:45:36
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

1. 問(wèn)題描述:

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

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

2. 解決方法:

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

mysql --user=root -p

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

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

create database python;

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

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, 以上方法不是最好的, 但卻是簡(jiǎn)單可行的,Enjoy it!!!

4、方法四:

這幾天用空密碼登錄mysql后,然后修改mysql默認(rèn)密碼,使用mysql表出現(xiàn)過(guò)這個(gè)問(wèn)題,提示:ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'。網(wǎng)上找了一些方法,終于搞定了。

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

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

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

skip-grant-tables

重啟mysql服務(wù),這時(shí)的mysql不需要密碼即可登錄數(shù)據(jù)庫(kù)
然后進(jìn)入mysql

mysql>use mysql;
mysql>update user set password=password('新密碼') WHERE User='root';
mysql>flush privileges;

運(yùn)行之后最后去掉my.ini中的skip-grant-tables,重啟mysqld即可。

修改mysql密碼方法二:
不使用修改my.ini重啟服務(wù)的方法,通過(guò)非服務(wù)方式加skip-grant-tables運(yùn)行mysql來(lái)修改mysql密碼
停止mysql服務(wù)
打開(kāi)命令行窗口,在bin目錄下使用mysqld-nt.exe啟動(dòng),即在命令行窗口執(zhí)行: mysqld-nt --skip-grant-tables
然后另外打開(kāi)一個(gè)命令行窗口,登錄mysql,此時(shí)無(wú)需輸入mysql密碼即可進(jìn)入。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 抚宁县| 弋阳县| 公主岭市| 嫩江县| 江西省| 洛川县| 五峰| 晋中市| 秦安县| 阿拉善右旗| 突泉县| 宜宾县| 高碑店市| 平舆县| 淅川县| 田东县| 沐川县| 林周县| 剑河县| 元阳县| 屯昌县| 胶南市| 合阳县| 湘乡市| 鄂尔多斯市| 交城县| 浦县| 博白县| 绵阳市| 宁乡县| 珠海市| 岳普湖县| 日照市| 德令哈市| 佳木斯市| 安仁县| 新邵县| 油尖旺区| 平邑县| 青神县| 鄂托克旗|