MySQL is an open-source relational database management system (RDBMS). I had always prepferred PostgreSQL but there are some reasons you can not avoid MySQL (more on this later). Here are the following steps I followed to get started with MySQL on ubuntu.
Download deb package that handles configuring and installing the official MySQL software repositories. You can download this package manually from following link
Alternatively, you can download this using curl
curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.3-1_all.deb
We need to pass two command line flags to curl. -O instructs curl to output to a file instead of standard output. The L flag makes curl follow HTTP redirects, necessary in this case because the address we copied actually redirects us to another location before the file downloads.
Install this file using following command
sudo dpkg -i mysql-apt-config_0.8.3-1_all.deb
You will get following window. Select ok. First and second options are already selected.
The package will now finish adding the repository. Refresh your apt package cache to make the new software packages available:
sudo apt-get update
Step#3 Install MySQL
Now you can install MySQL using following command.
sudo apt-get install mysql-server
It will ask for confirmation, Type y then ENTER.
You will be asked to set a root password during the configuration phase of the installation. Be sure to choose a secure password, enter it twice, and the process will complete.
During installation, you will be prompted for root password.
MySQL should be installed and running now. You can check the status MySQL using systemctl command:
systemctl status mysql
Step#4 Securing MySQL (Optional)
You can secure your MySQL database using following command
If you runinto any issues try reinstalling MySQL.
$ sudo apt-get remove -y mysql-* $ sudo apt-get purge -y mysql-* $ sudo apt-get purge mysql-server mysql-client $ mysql-common mysql-server-5.7 $ sudo apt-get autoclean $ sudo apt-get update && sudo apt-get upgrade
once done install MySQL using following command
$ sudo apt-get install mysql-server-5.7
Please note suffix -5.7 at the end. I am not sure why but it works with this prefix.