Ubuntu16 Install mysql5.7 not prompt for password, after installation, modify the MySQL password default password
MySQL default password is empty
But when you use the MYSQL-UROOT-P command to connect to MySQL, an error
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost '
At this point, you can change the root default password
--------------------------------------------------------------------------------------------------------------- ---------------------------
1. Go to the Etc/mysql directory and view the debian.cnf file
2. Locate your username, password, and log in to MySQL using this account.
User name: Debian-sys-maint
Password: XEDVSNKDLAVJUEWV
Login: MYSQL-UDEBIAN-SYS-MAINT-PXEDVSNKDLAVJUEWV
3. Change the password of the root user
Here is the key point, because mysql5.7 does not have a password field, the password is stored in the Authentication_string field, and the password () method can also be used
Execute the following statement in MySQL to modify the password
4. After changing the password, you need to restart MySQL
/etc/init.d/mysql restart;
Sign in again
Mysql-u root-p password;
It's OK.
--------------------------------------------------------------------------------------------------------------- ---------------------------
I uninstalled many times MySQL, reinstall or do not prompt to enter the password, this method solves the problem
Attach the steps to uninstall and install MySQL.
Unloading:
sudo apt purge mysql-*sudo rm-rf/etc/mysql//var/lib/mysqlsudo apt autoremove
Installation:
# when the installation will prompt to set the root password, if you do not uninstall the time to clean up the residual data is not prompted to set the root password, I do not prompt, you can use the method above to modify the password sudo apt-get install mysql-client Mysql-server #检查mysql是不是在运行sudo service MySQL status# General installation will automatically run after the completion, if not run can startsudo service MySQL start
Ubuntu16 Install mysql5.7 not prompt for password, after installation, modify the MySQL password default password