The root User Name in ubuntu cannot go to mysql. How can I view the user name and password and change the root password?
Mysql-u root-p Press enter. after entering the password, the system prompts "access denied... ues password YES/NO" error.
Step 1:
In this case, you need to enter the/etc/mysql directory, and then sudo vim/vi debian. cnf view the username and password in the file, and then use the username and password in the file to enter mysql. If debian. if the user name in cnf is debian-sys-maint, then:
Mysql-u debian-sys-maint-p press Enter. In this case, you need to enter the password and copy the password in debian. cnf (do not enter it manually because it is prone to errors ).
Now you can access mysql.
Step 2:
Change root Password
Log on to the mysql client according to the previous step.
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
Step 3:
Use the newly changed root and password to log on and view.