To install MySQL on an Ubuntu server, follow these steps:
- Update the package index:
sudo apt update
- Install the MySQL server package:
sudo apt install mysql-server
- During the installation process, you will be prompted to set a password for the root user. Make sure to choose a strong password and remember it, as you will need it later to manage your MySQL server.
- Once the installation is complete, run the following command to check the status of the MySQL service:
sudo systemctl status mysql
- If the MySQL service is not running, start it using the following command:
sudo systemctl start mysql
- To ensure that the MySQL service starts automatically at boot time, run the following command:
sudo systemctl enable mysql
- To log in to the MySQL server as the root user, run the following command:
mysql -u root -p
- You will be prompted to enter the password you set during the installation process. Once you have entered the correct password, you will be logged in to the MySQL server.
That's it! You have now successfully installed MySQL on your Ubuntu server.