To Install MySQL 8.0 on ubuntu 18.04. we will use latest .deb file to configure apt repository on ubuntu. Follow the steps one by one to install MySQL easily.
Step 1 – Add MySQL Apt Repository
Downloading the repository package using the wget or curl tool from the command line.
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb
Or use curl
curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb
Then install the MySQL repository package using the following dpkg command.
sudo dpkg -i mysql-apt-config_0.8.24-1_all.deb
Step 2: Install MySQL Server in Ubuntu 18.04
Next, download the latest package information from all configured repositories, including the recently added MySQL repository.
sudo apt update
Then run the following command to install packages for the MySQL community server
sudo apt-get install mysql-server
Through the installation process, you will be asked to enter a password for the root user for your MySQL server, re-enter the password to confirm it and press [Enter].
You will be asked to select the default authentication plugin to use, then use the right arrow to choose
Ok and press [Enter] to complete the package configuration.
Step 3: Secure MySQL Server Installation
By default, the MySQL installation is insecure.
Execute the below script
You will be asked to enter the root password you set during installation. Then also choose whether to use the VALIDATE PASSWORD plugin or not.
- Change the password for root: if you want then press
- Remove anonymous users? :
- Disallow root login remotely? :
- Remove test database and access to it? :
- Reload privilege tables now? :
Step 4: Managing MySQL Server via Systemd
To Know the Server Status run the below command
sudo systemctl status mysql
Step 5: Auto Restart On System or Server Boot
sudo systemctl enable mysql
Finally, to access the MySQL shell
sudo mysql -u root -p