Home >Database >Mysql Tutorial >修改mysql密码_MySQL

修改mysql密码_MySQL

WBOY
WBOYOriginal
2016-06-01 12:58:471048browse

1、如果没有密码,则

 

  mysql -u root

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

2、如果已经有密码,可以用:

 

  mysqladmin -u root password "newpass"

  如果root已经设置过密码,采用如下方法

  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)

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn