ubuntu apt-get install mysql forget your password, approach

Encounter this problem, look for a long time, still found, but it looks like the Mac's interface:

Transfer: https://www.cnblogs.com/WXGC-yang/p/10562203.html

 

 

A MySQL installation

sudo apt-get update

sudo apt-get install mysql-server

Two password problem

When prompted to set a password to install 1

This situation no problem, log on MySQL by order has been given

mysql -u root -p

No password when prompted to install 2

This situation can try to use an empty password to log in

3 no password prompt and a blank password can not log installation

I encountered no password prompt and empty password is invalid when you install MySQL, the following error message:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Three solutions (can also be used to forget the root password)

Ubuntu creates one for users when installing MySQL Debian-SYS-main t we can be set by the user this user

1 View debian-sys-maint password

sudo cat /etc/mysql/debian.cnf

2 Log debian-sys-maint user

mysql -u debian-sys-maint -p

Note: At this point just found the password for the password

Now we have to log in to the MySQL

3 Set the root password

use mysql;

update mysql.user set authentication_string=password('你的密码') where user='root' and Host ='localhost';

update user set plugin="mysql_native_password";

flush privileges;

quit;

OK! Problem solved

 

Guess you like

Origin www.cnblogs.com/linwenbin/p/11490828.html