To install MySQL on a Linux machine, follow these steps:
- Open a terminal window.
- Update the package index by running the command:
sudo apt update
- Install the MySQL server package by running the command:
sudo apt install mysql-server
- During the installation process, you will be prompted to set a password for the MySQL "root" user. Choose a strong password and remember it.
- Once the installation is complete, start the MySQL service by running the command:
sudo systemctl start mysql
- Enable the MySQL service to start on boot by running the command:
sudo systemctl enable mysql
- Verify that the MySQL service is running by running the command:
sudo systemctl status mysql
The status should show "active (running)".
- Secure the MySQL installation by running the command:
This will prompt you to make various security-related choices for your MySQL installation. It is recommended to select "Y" (yes) for all options.
After following these steps, MySQL should be successfully installed on your Linux machine.