Ubuntu install MySQL password initialization problem

sudo apt-get install mysql-server mysql-common After installing MySQL using the command on Ubuntu , there is no password prompt during installation. Then use mysql -u root -p it to log in, and then ask for a password, but no matter how you enter it, it prompts that the password is wrong. How to solve it?

 

The plan is as follows:

  1. Open the /etc/mysql/debian.cnf file. In this file, there is a user name and password assigned by the system by default. Through this password, you can directly operate MySQL.
  2. Log in with debian-sys-maint as the user name, and the password is the one in debian.cnf. Use mysql -u debian-sys-maint -p to log in.
  3. After entering mysql, modify the password of MySQL. The specific operation is as follows: use the command: set password for 'root'@'localhost' = password('yourpass');After the modification, you can operate MySQL normally.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325256086&siteId=291194637