A Step-by-Step Guide
Introduction:
MySQL is a popular open-source relational database management system used for storing and managing data in various web applications. In this guide, we will walk through the step-by-step process of installing MySQL Server on both Ubuntu and CentOS operating systems.
- Installing MySQL Server on Ubuntu:
Step 1: Update Package Index:
sudo apt update
Step 2: Install MySQL Server:
sudo apt install mysql-server
Step 3: Start and Enable MySQL Service:
sudo systemctl start mysql
sudo systemctl enable mysql
Step 4: Secure MySQL Installation:
sudo mysql_secure_installation
Follow the prompts to set up a root password and secure the MySQL installation.
- Installing MySQL Server on CentOS:
Step 1: Add MySQL Yum Repository (for CentOS 8):
sudo dnf install https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
For CentOS 7, replace el8
with el7
in the URL.
Step 2: Install MySQL Server:
sudo dnf install mysql-server
Step 3: Start and Enable MySQL Service:
sudo systemctl start mysqld
sudo systemctl enable mysqld
Step 4: Secure MySQL Installation:
sudo mysql_secure_installation
Follow the prompts to set up a root password and secure the MySQL installation.
- Verifying MySQL Installation:
Step 1: Check MySQL Service Status:
sudo systemctl status mysql
Step 2: Access MySQL Shell:
sudo mysql -u root -p
Enter the root password when prompted.
Step 3: Verify MySQL Version:
SELECT VERSION();
This command displays the MySQL server version.
You have successfully installed MySQL Server on both Ubuntu and CentOS operating systems. MySQL is now ready to use for storing and managing your application’s data.