Ubuntu 18.04 How To Install, Reinstall And Uninstall MySQL - Softhints
Maybe your like
In this post you can find information about Ubuntu 18.04 and MySQL how to install, reinstall and uninstall it completely. Below you can find all topics:
- Install MySQL default package
- Testing MySQL
- Connect to MySQL
- Install mysql 8 Ubuntu 18.04
- Reinstall MySQL server
- Uninstall MySQL server
- complete uninstall
- uninstall
- Install MySQL Workbench
- MySQL services
- Duplicate Entire MySQL Database
This article will install the default package for the Ubuntu which is still MySQL 5.7. If you want to install MySQL 8 (or any other version) than you can follow this instructions:
How to install MySQL 8 on Ubuntu 16.04
Install MySQL default package
Update your package version in order to install latest possible version. Then install MySQL server by installing the default package. Optionally you can install additional libraries for MySQL like workbench. The last command is needed if you want to configure your server security. This script will delete test data, password levels will be set up and root account password will be changed:
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_installationTesting MySQL
After the successful installation MySQL should start automatically. You can test it by:
systemctl status mysql.serviceYou'll see output similar to the following:
Output:
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)If you are able to see it then this means MySQL is up and running.
Connect to MySQL
Connection to MySQL with user root and password with(you will be prompted for the password) : mysql -u [username]-p
mysql -u root -pAfter successful connection you can start running queries.
Install mysql 8 Ubuntu 18.04
You can install the latest version (currently 8) by manually adding MySQL's repository first.
- First you need to update your system:
- Install MySQL 8 by adding APT Repository
- Download MySQL APT Repository from: MySQL APT Repository (Click Download on the bottom right, then copy the link on the next page ( from No thanks, just start my download)). Sample code:
- Install the APT by dpkg
At this step you need to select what to be installed and press OK.
sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb- Install the MySQL Server 8
- During installation you will be asked for root password. Select a good one and continue installation
reinstall MySQL server
Full version
Reinstalling is a process which consists of two steps: removing the old MySQL installation and then installing a new one. First to remove or uninstall MySQL Client Core 5.7 you need to run:
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/mysqlNow install or reinstall MySQL client and server(or the one that you need):
sudo apt-get install mysql-server sudo apt-get install mysql-client sudo apt-get install mysql-workbench sudo mysql_secure_installationShort version:
First remove MySQL:
sudo apt-get remove --purge mysql-server mysql-client mysql-common sudo apt-get autoremove sudo apt-get autocleanThen reinstall:
sudo apt-get update sudo apt-get install mysql-server mysql-client mysql-common sudo mysql_secure_installationUninstall MySQL server
Completely uninstall MySQL from Ubuntu 18.04(tested also on Ubuntu 16 and Linux Mint):
sudo apt-get remove --purge mysql* sudo apt-get autoremove sudo apt-get autocleanCompletely uninstall MySQL Client Core 5.7:
sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.7 mysql-client-core-5.7 sudo rm -rf /etc/mysql /var/lib/mysql sudo apt-get autoremove sudo apt-get autoclean sudo rm -rf /var/lib/mysql sudo rm -rf /etc/mysqlInstall MySQL Workbench
In order to install MySQL Workbench the best is first to update the system by:
sudo apt-get update sudo apt-get upgradeThen you need to add the repository:
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.rpmAnd finally install it with
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.debMySQL services
After Ubuntu 15.04
systemctl start mysql # Use it to start a MySQL. Does not persist after reboot systemctl stop mysql # Use it to stop a MySQL. Does not persist after reboot systemctl restart mysql # Use it to restart a MySQL systemctl reload mysql # If the MySQL supports it, it will reload the config files related to it without interrupting any process that is using the MySQL. systemctl status mysql # Shows the status of a MySQL. Tells whether a MySQL is currently running. systemctl enable mysql # Turns the MySQL on, on the next reboot or on the next start event. It persists after reboot. systemctl disable mysql # Turns the MySQL off on the next reboot or on the next stop event. It persists after reboot. systemctl show mysql # Show all the information about the MySQL.Before Ubuntu 15.04
sudo start mysql #START sudo stop mysql #STOP sudo restart mysql #RESTARTDuplicate Entire MySQL Database
Two times will be prompted for password.
mysqldump -u admin -p originaldb | mysql -u backup -pPassword duplicateddb; mysqldump -u root -p mydb | mysql -u root -p mydbCopy;Tag » How To Reinstall Mysql 8
-
MySQL 8.0 Reference Manual :: 2 Installing And Upgrading MySQL
-
MySQL Installation Guide
-
Ubuntu Mysql Uninstall / Reinstall - Stack Overflow
-
How Do I Uninstall And Reinstall MySQL? - DigitalOcean
-
How To Reinstall Mysql? - Ask Ubuntu
-
Completely Uninstall OR Remove MySQL 8 From Windows 10
-
Completely Remove Or Uninstall MySQL 8 Database From Windows 11
-
How To Reinstall MySQL V5.x On Linux - NixCraft
-
How To Install MySQL 8.0 (on Windows, MacOS, Ubuntu) And Get ...
-
MySQL: Start, Stop, Uninstall & Reset Password - Academind
-
Uninstalling MySQL 8 - Packt Subscription
-
Cleanly Reinstall Mysql 8 | DirectAdmin Forums
-
Reinstall MySql On Windows Server 2008 - Stison
-
Reinstall Mysql Database With Too Manny Errosr... - MariaDB