mysql找回密码

 redhat5下安装MySQL-5.6,默认装完没有设置mysql的密码,按理说应该mysql的root用户的默认密码为空,但是默认空密码无法进入,报错信息如下: 

Java代码  收藏代码

Access denied for user 'root'@'localhost' (using password: NO)  

各种密码尝试都无法进入mysql。经网上查找资料终于找到解决办法。 

解决办法: 

找到my.cnf文件,编辑文件,添加如下内容: 

  skip-grant-tables 

     skip-networking 

红色字体为新添加。 

Java代码  收藏代码

[root@localhost /]# vi /usr/my.cnf   

# For advice on how to change settings please see  

http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html  

[mysqld]  

[color=red]   

  skip-grant-tables  

  skip-networking  

[/color]  

# Remove leading # and set to the amount of RAM for the most important data  

# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.  

# innodb_buffer_pool_size = 128M  

# Remove leading # to turn on a very important data integrity option: logging  

# changes to the binary log between backups.  

# log_bin  

# These are commonly set, remove the # and set as required.  

# basedir = .....  

重新启动:/etc/init.d/mysql restart 

启动OK后,mysql的root用户默认空密码可以正常进入。

update mysql.user set password=password('root') where User="root" and Host="localhost";

5.7

update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';

flush privileges;  #刷新系统授权表

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值