How to Reinstall MySQL in Ubuntu [Complete Guide]

then you can read & follow our instructions to fix. One possible to fix this issue is to reinstall or update MySQL. In this post, we are discussing on How to Reinstall MySQL in Ubuntu in details and providing easy steps to do so.
Users reported that MySQL is not starting up while they entered into command line and states that you can’t login with password which they generated during setup installation. They have already reported about this issue on various online popular platforms and asked for the solution.
One user explained that “I am new to Ubuntu, when I first installed MySQL it was during LAMP setup on Ubuntu based machine. I am trying to get a fresh or clean install of only MySQL to fix “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)”. I still can’t find what my issue is. Is there any solution?” If you are one of them who are facing the same or for some other reasons, you want to reinstall MySQL in Ubuntu, then you are in right place for that.
Ubuntu: Ubuntu is an open source Debian-based Linux distribution available for personal computers (PCs) and servers. The word “Ubuntu” is belongs to African Zulu language that refers to “Humanity to others”. Primarily, Ubuntu employs GNOME (GNU Network Object Model Environment) that is Graphical User Interface (GUI) and set of desktop applications for Linux. GNOME is intended to make Linux easy to uses for each user especially for non-programmers which are similar to Microsoft Windows interface. Some variants of Ubuntu are:
- Edubuntu: for educational institutions and home schooling
- Kubuntu: a version that employs KDE (Kool Desktop Environment) instead of GNOME
- Ubuntu Server Edition
- Ubuntu Studio: for multimedia applications
- Xubuntu: for computers with limited processing power
- JeOS: a lightweight version for virtual appliances.
MySQL: SQL stands for Standard Query Language. MySQL is RDBMS (Relational Database Management System) based on SQL that is used for wide range of purposes including data warehousing, e-commerce and logging applications. It is possible to create websites in association with a scripting language like PHP or Perl which will interact in real-time with MySQL database to show searchable result to website’s users.
How to Reinstall MySQL in Ubuntu?
Method 1: Install MySQL default package
Step 1: Update your MySQL package to its latest version
Step 2: Install MySQL server by installing default package
Step 3: (Optional) Install additional library for MySQL like Workbench
Step 4: The last command will required if you want to configure your server security. This will delete test data, passwords levels will be set up and root account password will be changed.
Use these commands:
sudo apt-get update
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install mysql-workbench
sudo mysql_secure_installation
Method 2: Test MySQL
The above commands can be used to install MySQL successfully on Ubuntu. To test it, type the following command in “Terminal”
systemctl status mysql.service
You will see output similar to following:
mysql.service – MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
Active: active (running) since Wed 2016-11-23 21:21:25 UTC; 30min ago
Main PID: 3754 (mysqld)
How to Reinstall MySQL 8 in Ubuntu 18.4?
Step 1: Update your System by entering following command in Ubuntu Terminal
sudo apt-get update
sudo apt-get upgrade
Step 2: Download MySQL APT Repository from “MySQL APT Repository” official website (On the page, click on “Download” button and then copy the link on the next page). Sample code:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb
Step 3: Type the following command to install APT by dpkg
sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb
Step 4: Now, install MySQL Server 8 by executing following command
sudo apt-get update
sudo apt-get install mysql-server
Step 5: During installation process, you will be asked for root password. Select a password and continue the installation
How to uninstall and reinstall MySQL Server? [Full Version]
To uninstall, run the following command:
sudo apt-get remove –purge mysql-server mysql-client mysql-common
sudo apt-get remove –purge mysql-client-core-5.7
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
To install or reinstall, run the following command:
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install mysql-workbench
sudo mysql_secure_installation
Note: At first, you need to remove old MySQL installation, and then install a new one. Run each command one-by-one and hit “Enter” key after each to execute
How to Install MySQL workbench?
Step 1: At first, you need to update your System by executing following command
sudo apt-get update
sudo apt-get upgrade
Step 2: Add the repository by
sudo dpkg -i mysql-apt-config_0.3.1-1ubuntu14.04_all.deb
sudo apt-get install mysql-workbench-community
sudo rpm -Uvh mysql-community-release-el7-5.noarch.rpm
Step 3: Now, install it using following command
wget http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community-6.0.9-1ubu1310-amd64.deb
sudo dpkg -i mysql-workbench-community-6.0.9-1ubu1310-amd64.deb
Conclusion
I am sure this article helped you to fix MySQL issues and reinstall or update MySQL on Ubuntu based machine with easy steps. You need to follow each step carefully to complete this reinstall process. If this post really helped you, then you can share it with others to help them. For any suggestions or queries, please write on comment box given below.