MySQL
Install
My enviroment:
Architecture: x86_64
OS: Ubuntu 22.04 LTS
Update packages then install mysql:
sudo apt update
sudo apt upgrade
sudo apt install mysql-server
Test if it works and check version:
sudo systemctl enable mysql
sudo systemctl start mysql
sudo systemctl status mysql
mysql -V
Security
Warning: Before runing mysql_secure_installation script
An error occurs as of July 2022, when you runmysql_secure_installation script without some further configuration.
Login to mysql as root without providing password:
sudo mysql -uroot
Enter the following command to set root's password with the <password> replaced by your password:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>';
Exit:
exit
Enhance your database security by running mysql_secure_installation script:
sudo mysql_secure_installation
choose the options:
- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y
Then you can login to mysql as root with password:
mysql -u root -p
Last updated