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:
- 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.
- 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. - 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.