This is the fifth day of my participation in the August More text Challenge. For details, see:August is more challenging

A MySQL installation

sudo apt-get update

sudo apt-get install mysql-server

Two Password problems

1 The system prompts you to set the password

In this case, there is no problem. Log in to MySQL using the command that you have run

mysql -u root -p

2 No password is prompted during the installation

In this case, try logging in with an empty password

3 No password is displayed during the installation and the login fails if the password is empty

MySQL > install MySQL > install MySQL > install MySQL > install MySQL > install MySQL

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

Three solutions (also used to forget root password)

When Ubuntu installs MySQL, it creates a debian-sys-maint user for the user

1 View the debian-sys-maint password

sudo cat /etc/mysql/debian.cnf

2 Log in to the debian-sys-maint account

mysql -u debian-sys-maint -p

Note: The password is the one just found

Now we have logged in to MySQL

3 Set the root password

use mysql;

Update mysql.user set authentication_string=password(‘ your password ‘) where user=’root’ and Host =’localhost’;

update user set plugin=”mysql_native_password”;

flush privileges;

quit;

OK! Problem solved