Install MYSQL 8 on UBUNTU

How to Install MySQL 8 on Ubuntu

Step 1: Update Your System

Before installing MySQL 8, ensure that your system is up-to-date by running the following commands:

sudo apt update
sudo apt upgrade -y

Step 2: Install MySQL Server

Install MySQL Server 8 on Ubuntu using the following command:

sudo apt install -y mysql-server

Step 3: Start and Enable MySQL

After installation, start the MySQL service and enable it to start automatically on boot:

sudo systemctl start mysql
sudo systemctl enable mysql

Step 4: Secure Your MySQL Installation

Secure your MySQL installation by running the security script:

sudo mysql_secure_installation

Follow the prompts to set a new root password and secure your MySQL installation.

Step 5: Verify MySQL Installation

Verify that MySQL has been successfully installed by running the following command:

sudo mysql -u root -p

Enter the root password you set during the secure installation. If you can successfully log in, you've completed the installation of MySQL 8 on Ubuntu.

Step 6: MySQL Configuration (Optional)

If needed, customize your MySQL configuration by editing the my.cnf configuration file located in /etc/mysql/my.cnf.

Step 7: Start and Enable MySQL on Boot

If MySQL is not already running, you can start it and enable it to start automatically on boot with these commands:

sudo systemctl start mysql
sudo systemctl enable mysql

That's it! You've successfully installed and configured MySQL 8 on Ubuntu. You can now use MySQL to create databases, manage user accounts, and run SQL queries on your server.

Related Articles