---
title: "mysql -uroot -p ; access denied "
author: "jacklin2015"
date: "2016-01-25T15:01:34Z"
tags: ["MySQL"]
categories: ["数据库"]
slug: "mysql-uroot-p-access-denied"
draft: false
lastmod: "2016-01-25T15:01:34Z"
id: 2273720
url: "https://jacklin2015.iteye.com/blog/2273720"
---

imeadmin@imeadmin:~/redmine-2.4.1-1/mysql$ bin/mysql  -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

solution：
imeadmin@imeadmin:~/redmine-2.4.1-1/mysql$ vim my.cnf   
在 [mysqld]  加入 skip_grant_tables
重启 imeadmin@imeadmin:~/redmine-2.4.1-1/mysql$ ../ctlscript.sh restart mysql

imeadmin@imeadmin:~/redmine-2.4.1-1/mysql$ bin/mysql  -uroot mysql

mysql> UPDATE user SET Password=PASSWORD('root123') where USER='root';  

mysql> FLUSH PRIVILEGES;      

mysql> quit

把 my.cnf 里 [mysqld] 的 skip_grant_tables 去掉 ，再重启 mysql 就ok了。




