To install MySQL 8 on Ubuntu, you can follow these steps:
- Update the package index on your Ubuntu system by running the following command:
sudo apt update
- Install the MySQL APT repository package by executing the following command:
sudo apt install mysql-apt-config
- During the installation, you'll be prompted to configure the MySQL APT repository. Select "MySQL Server & Cluster (Currently selected: mysql-8.0)" using the arrow keys and press Enter.
- Once the configuration is complete, update the package index again:
sudo apt update
- Install the MySQL server package by running the following command:
sudo apt install mysql-server
- During the installation, you'll be prompted to set a password for the MySQL root user. Enter a strong password and remember it, as it will be required for administrative tasks.
- Once the installation is complete, you can start the MySQL service by running the following command:
sudo service mysql start
-
To ensure that MySQL starts automatically upon system boot, execute the following command:
sudo systemctl enable mysql
That's it! MySQL 8 should now be installed and running on your Ubuntu system. You can test the installation by accessing the MySQL shell using the following command:
sudo mysql_secure_installation
Follow the on-screen prompts and make the appropriate selections to secure your MySQL installation.
Please note that the above instructions assume you are using Ubuntu's default package manager, apt, and the steps are specific to Ubuntu-based systems. If you are using a different Linux distribution, the installation process may vary slightly.