There is no setting password interface when mysql 8.0 is installed and how to update the root password Ubuntu 20.04
Ubuntu installs mysql and does not jump out of the interface for entering the password. After the installation is complete, you cannot enter root. Error ERROR1698(28000): Access denied
The main reason for this problem is that mysql has been installed on the target host and commands such as apt purge only delete the mysql configuration file when uninstalling, and the mysql user name is stored in the database, corresponding to the folder
/var/lib/mysql, and when it is installed again , The mysql installer does not have permission to change the original database, so it will create a temporary user name and save it in the folder by default
Such as (the picture comes from the network, I forgot to take the screenshot when I matched it):
The most straightforward way is to delete
/var/lib/mysqlthe contents saved in the folder and reinstall.
Uninstall the old mysql:
sudo sysytemctl stop mysql sudo apt purge mysql-*
Delete database file
cd /var/lib sudo rm -rf mysql
The installation will return to normal at this time
sudo dpkg -i mysql-apt-config_0.8.17-1_all.deb # 版本号可能不同 sudo apt update sudo apt install mysql-server
If it is not necessary to recommend solution 1, the idea of solution 2 is feasible but the blogger has not verified it on his own machine.
The idea of solution 2 is to log in with a temporary account password, and then change the root password. The temporary account password is stored in a
``` mysql -u debian-sys-maint -p # enter 后输入文件中显示的密码 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; mysql> FLUSH PRIVILEGES mysql> exit; sudo systemctl restart mysql ```
After logging in with the new password, you can refer to the official document: mysql Official Root Password Change Tutorial . If the solution 2 prompts that there is no permission, you can use the official method to directly change the root password, and it is strongly recommended to use the solution one directly. It should be noted that mysql8.0 has abandoned the password() function for security reasons, and many of the old methods of changing the root password are no longer applicable.