日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發(fā)布時(shí)間:2023/12/20 数据库 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 error 1044 mysql_mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1. 問題描述:

在MySQL控制臺(tái)下創(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)入控制臺(tái):

mysql --user=root -p

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

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

4、方法四:

這幾天用空密碼登錄mysql后,然后修改mysql默認(rèn)密碼,使用mysql表出現(xiàn)過這個(gè)問題,提示: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)是因?yàn)閙ysql數(shù)據(jù)庫的user表里,存在用戶名為空的賬戶即匿名賬戶,導(dǎo)致登錄的時(shí)候是雖然用的是root,但實(shí)際是匿名登錄的,通過錯(cuò)誤提示里的''@'localhost'可以看出來。我用方法一解決了問題,

方法一:

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

skip-grant-tables

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

然后進(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ù)的方法,通過非服務(wù)方式加skip-grant-tables運(yùn)行mysql來修改mysql密碼

停止mysql服務(wù)

打開命令行窗口,在bin目錄下使用mysqld-nt.exe啟動(dòng),即在命令行窗口執(zhí)行: mysqld-nt --skip-grant-tables

然后另外打開一個(gè)命令行窗口,登錄mysql,此時(shí)無需輸入mysql密碼即可進(jìn)入。

按以上方法修改好密碼后,關(guān)閉命令行運(yùn)行mysql的那個(gè)窗口,此時(shí)即關(guān)閉了mysql,如果發(fā)現(xiàn)mysql仍在運(yùn)行的話可以結(jié)束掉對(duì)應(yīng)進(jìn)程來關(guān)閉。

啟動(dòng)mysql服務(wù)。

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

總結(jié)

以上是生活随笔為你收集整理的error 1044 mysql_mysql ERROR 1044 (42000): Access denied for user ''@'localhost' to database的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。