We can install MySQL 8 server on ubuntu using repository or source code. We can also download the deb package of MySQL on ubuntu. Let’s see, how to install MySQL 8 on ubuntu.
How To Install MySQL 8 Server On Ubuntu 20.04 /19.10
Before starting the installation of MySQL, we need to download and install the packages. we will install the wget that will download the package from the internet. Once the package is downloaded, we can use dpkg command to install it.
sudo apt install wget -y sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
It will ask you which MySQL product would you like to install. Right now, we will install MySQL server 8. Click on “OK” and “Enter“.
Once the repository is installed or enabled. you can use the below command to install.
sudo apt install mysql-server
Press “y” and Enter. it will start the installation. Now, it will you to set the MySQL root password.
Again, it will ask you to confirm the root password then click on “OK”.
Click on “OK” and use the default encryption which is recommended.
Now it will start the installation. we can check the version using the below command.
sudo apt policy mysql-server
Use the below commands to check the port listening on 3306, enable the MySQL if it’s stopped, and check the status.
sudo apt netstat -tnlp | grep 3306 sudo systemctl enable --now mysql sudo systemctl status mysql
If everything is OK., try to login with the root user using the below command.
sudo mysql -u root -p
Now we will create a database, select that database, and show all the databases as shown in the below figure.