mysql 默认根密码,如何将MySQL根密码更改为默认密码?

My initial installation for the MySQL had no password for root. I assigned a password for root and everything worked fine. Due to some reason (don't ask why) I had to revert back to the original settings where root didn't have any password.

I changed the root password to '' (empty string). The problem now is that MySQL doesn't run with 'mysql -uroot', it expects a password. On running 'mysql -uroot -p' and hitting enter on the password prompt gets me into the db, but is not same as the default setting.

Is there any other flag/setting that I am missing to set/unset which tells mysql to not expect a password?

Thanks

解决方案

How to Reset MySQL root password:

To reset it, see How to Reset the Root Password in the MySQL manual.

How to run MySQL without password controlled access

To run MySQL with the password controls disabled, check out the --skip-grant-tables option.

How to avoid typing credentials on the command line

If you simply want to avoid having to type the password on the mysql command line, create a file called .my.cnf (note leading period on that filename!) in your home directory. In your case, for the root user, probably /root

Add the following entries to the file

[client]

host=localhost

user = root

password = mypassword

database = mydatabase

You'd typically chmod 600 this file so that only you can see it, and MySQL will ignore a .my.cnf which is world writable anyway.

See the manual page Using Option Files for more information

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值