---
title: "MYSQL ERROR 1045 错误的解决办法"
author: "05150212"
date: "2010-03-26T22:59:31Z"
tags: ["Linux", "MySQL", "RedHat", "Windows", "软件测试"]
categories: ["数据库"]
slug: "mysql-error-1045"
draft: false
lastmod: "2010-03-26T23:00:07Z"
id: 625844
url: "https://05150212.iteye.com/blog/625844"
---

ERROR 1045 (28000): Access denied for user['root'@'localhost'](mailto:-root-@-localhost-)(using password:YES)

 

windows下：

 

第一步：打开开始里[**MYSQL**]()的MySQL Command Line Client 输入你的密码[就是安装时设的那个 

第二步：在mysql&gt;后输入：UPDATE mysql.user SET Password = OLD\_PASSWORD('密码') 

第三步：在提示符-&gt; 后输入：WHERE Host = 'localhost' AND User = '用户名';51Testing软件测试网j!cu X1R  
回车后提示：Query OK, 0 rows affected (0.16 sec) Rows matched: 0 Changed: 0 Warnings: 0

第四步：在mysql&gt;后输入：FLUSH PRIVILEGES;   
回车后提示：Query OK, 0 rows affected (0.19 sec) 

 

linux下：

 

启动mysql服务，登录到mysql数据库，输入命令为：

\[root @localhost root]# /usr/bin/mysql -u root -p *

（依据lniux版本兼容问题，－p 后面输入的内容将有所不同）

－p: [**数据库**]()管理员root的密码 （一般输入该密码）

－p: 指定将使用的数据库名

 而后 ，Enter password:在这里输入数据库的密码 （redhat 9.0版本）

在redhat 9.0版本下，如果 直接输入数据库管理员root的密码，将出现1045错误.