Install MySQL on Ubuntu 16.04

Download and Add the MySQL APT Repository

Sometimes the APT reference from cloud provider does not complete although we already did apt-get update
So we need to download MySQL debian package from the original source.

Download MySQL APT repository at http://dev.mysql.com/downloads/repo/apt/.

1
2
3
4
5
6
root@abcdefg:~# cd /
root@abcdefg:/# mkdir download
root@abcdefg:/# cd download/
root@abcdefg:/download# wget https://repo.mysql.com//mysql-apt-config_0.8.9-1_all.deb
root@abcdefg:/download# sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb
root@abcdefg:/download# sudo apt-get update

Instal MySQL Server and Check The Service

1
2
3
4
root@abcdefg:~# sudo apt-get install mysql-server
root@abcdefg:~# mysql_secure_installation
root@abcdefg:~# systemctl status mysql.service
root@abcdefg:~#

Uninstall MySQL (Incase You Get A Problem)

1
2
3
4
5
6
7
8
root@abcdefg:~# sudo service mysql stop  #or mysqld
root@abcdefg:~# sudo killall -9 mysql
root@abcdefg:~# sudo killall -9 mysqld
root@abcdefg:~# sudo apt-get remove --purge mysql-server mysql-client mysql-common
root@abcdefg:~# sudo apt-get autoremove
root@abcdefg:~# sudo apt-get autoclean
root@abcdefg:~# sudo deluser mysql
root@abcdefg:~# sudo rm -rf /var/lib/mysql

Reference:

© 2017 - Muh Rizal
Powered by Hexo