CentOs5.5 卸载 及 安装 MYSQL 的经验

在操作CentOs下的mysql数据库时,遇到了一系列问题,如下:


1. 本地连接时ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

2. 远程连接时1130-host ... is not allowed to connect to this MySql server

3. 更改了root的密码后,登陆时提示ERROR 1044 (42000): Access denied for user 'root'@'localhost'.....
 

我的解决办法如下:

1. service mysqld stop #停止mysql服务

2. yum remove mysql #卸载mysql

3. cd /var/lib  #这里有mysql的文件夹,里面放的是数据库文件

4. mkdir mysqlbac

5. mv mysql mysqlbac  #把没有卸载干净的文件备份,以防万一,这步一定要做,否则下面的操作完成后还有问题

6. yum install mysql-server #重新安装mysql

7. service mysqld start #启动mysql服务

8. mysql -uroot mysql #以root身份进入mysql数据库

9. update user set password = password('123456') where user='root' #将root的密码设置为123456

10. flush privileges 

11. exit
 

通过以上11步,我上面的问题都解决了。

猜你喜欢

转载自mcj8089.iteye.com/blog/1472379