Step 1: Update Your System
Before we begin, it’s important to ensure that your system is up-to-date. To do this, open the terminal and run the following command:
sudo apt update && sudo apt upgrade -y
This command will update your system and install any available updates.
Step 2: Install MySQL
To install MySQL, run the following command in the terminal:
sudo apt install mysql-server
This will install the MySQL server and client packages.
Step 3: Configure MySQL
After installing MySQL, you need to configure it. To do this, run the following command:
sudo mysql_secure_installation
This command will ask you a series of questions and configure MySQL based on your answers. You will be prompted to set the MySQL root password, remove anonymous users, disallow root login remotely, and remove test databases.
Step 4: Start and Enable MySQL
To start MySQL, run the following command:
sudo systemctl start mysql
To enable MySQL at boot time, run the following command:
sudo systemctl enable mysql
Step 5: Verify MySQL Installation
To verify that MySQL is installed and running correctly, run the following command:
sudo systemctl status mysql
This command will show you the status of the MySQL service.
Frequently Asked Questions
Can I install MySQL on other versions of Ubuntu?
Yes, MySQL can be installed on other versions of Ubuntu as well.
What is the root password for MySQL?
You set the root password during the MySQL configuration step.
Can I access MySQL remotely?
By default, root login remotely is disallowed. You can change this during the configuration step if you want to access it remotely.
What are the system requirements for MySQL?
MySQL can run on any system that meets its minimum requirements. You can check the requirements on the MySQL website.
How do I uninstall MySQL?
To uninstall MySQL, run the following command in the terminal:
sudo apt remove mysql-server