Rabu, 16 Mei 2018

Totally uninstall MySQL Server Ubuntu

When you uninstall MySQL for any purpose and reinstall the MySQL Server, perhaps you want to fresh install for all the configuration, but you found that the configuration still remains.

Try this lists accordingly:

sudo service mysql stop  #or mysqld
sudo killall -9 mysql
sudo killall -9 mysqld
sudo apt-get remove --purge mysql-server mysql-client mysql-common

sudo deluser -f mysql
sudo rm -rf /var/lib/mysql
sudo apt-get purge mysql-server-core-5.7
sudo apt-get purge mysql-client-core-5.7
sudo rm -rf /var/log/mysql
sudo rm -rf /etc/mysql

sudo apt-get autoremove
sudo apt-get autoclean


Install MYSQL Server on Ubuntu 18.04



In case we need to install mysql server on ubuntu (18.04 LTS used as case), follow the instruction
  1. Install MySQL Server
    • sudo apt-get update
    • sudo apt-get install mysql-server

  2. Allow the remote access
    • sudo ufw allow mysql

  3. Start MySQL Server
    • sudo systemctl start mysql

  4. Set MySQL to launch at reboot
    • sudo systemctl enable mysql

  5. Set MySQL password
    • sudo /usr/bin/mysql -u root -p
    • mysql> use mysql;
    • mysql> UPDATE user SET authentication_string=PASSWORD('yourpassword') WHERE User='root';
    • mysql> FLUSH PRIVILEGES;