Home > Database > Mysql Tutorial > body text

ubuntu下root用户名进不去mysql,如何查看用户名和密码,如何修_MySQL

WBOY
Release: 2016-06-01 13:06:28
Original
1037 people have browsed it

Ubuntu

mysql -u root -p 按回车,输入密码后提示access denied......ues password YES/NO的错误。

第一步:

这时你需要进入/etc/mysql目录下,然后sudo vim/vi debian.cnf查看里面的用户名和密码,然后使用这个文件中的用户名和密码进入mysql,假如debian.cnf中的用户名为debian-sys-maint,则:

mysql -u debian-sys-maint -p按回车,这时需要你输入密码,复制debian.cnf中的密码(不要手动输入,因为容易产生错误)。

此时你能进入到mysql里面了。


第二步:

修改人root密码

根据上一步登录mysql客户端
mysql> use mysql;
Database changed
mysql> update user set password=password('new password') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit


第三步:

用新改的root和密码登录查看。



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template