1Open the terminal and enter
If the installation is too slow, configure the mirrorUbuntu sets domestic mirror_023's Xiao Chen's blog-CSDN blog
sudo apt install mysql-server
Installing through the command will install the latest mysql
If you install mysql8.0 for the first time, you must follow the following sequence, otherwise there will be many pitfalls.
2Use this command to enter mysql
sudo mysql
3 Enter the following command on the sql command line and press Enter, you can change the password tomynewpassword
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';
4 exit to return to the terminal command line and enter:
sudo mysql_secure_installation
Initialize configuration information
- VALIDATE PASSWORD COMPONENT..... (use password strength verification component) Input: n
- New Password: (Set a new password and repeat it)
- Remove anonymous users n
- Disallow root login remotely (reject remote root account login) n
- Remove test database and access to it(remove test database) n
- Reload privilege tables now (reload privilege tables now) y
At this point, the installation of mysql is completed and the password is configured.
Use sudo -u root -p to log in to mysql to verify whether the password is set successfully.
If you don’t follow the above steps and you have a lot of problems, the solution is:
Uninstall, then reinstall and follow the above steps
See here for uninstallation: Completely delete clean mysql (including configuration files) in ubuntu_023's Xiao Chen's blog-CSDN blog