首页 > 代码库 > 改动mysqlpassword

改动mysqlpassword

1、假设没有password,则

  mysql -u root

  mysql> SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘newpass‘);

2、假设已经有password,能够用:

  mysqladmin -u root password "newpass"

  假设root已经设置过password。採用例如以下方法

  mysqladmin -u root password oldpass "newpass"

3、能够在可视化界面中,找到mysql数据库的user表,改动,可是记得加权限:

grant all on mysql.* to ‘root‘@‘localhost‘ identified by ‘password‘; 

最后那个password即是你要改动的root用户的密码 

假设不加这句的话。会没有权限而登不上,回报这种错误:

错误代码  1045 

Access denied for user ‘root‘@‘localhost‘ (using password:YES) 

改动mysqlpassword