G. Sudarshan
Installing MySQL Server
- Install the MySQL server by using the Ubuntu operating system package manager:
sudo apt-get update
sudo apt-get install mysql-server
If the secure installation utility does not launch automatically after the installation completes, enter the following command:
sudo mysql_secure_installation utility
Allow remote access
If you have ip tables enabled and want to connect to the MySQL database from
another machine, you must open a port in your server’s firewall (the default
port is 3306). You don’t need to do this if the application that uses MySQL
is running on the same server.
Run the following command to allow remote access to the mysql server:
sudo ufw enable
sudo ufw allow mysql
Start the MySQL service
After the installation is complete, you can start the database service by
running the following command. If the service is already started, a message
informs you that the service is already running:
sudo systemctl start mysql
Start the MySQL shell
There is more than one way to work with a MySQL server, but this article
focuses on the most basic and compatible approach, the mysql
shell.
- At the command prompt, run the following command to launch the
mysql
shell and enter it as the root user:
/usr/bin/mysql -u root -p
Installing MySQL Workbench
Step 1: Download configuration file from the apt repository
Using this method, you can install MySQL from the official apt
repository. For this purpose, download the repository configuration file
from the given URL https://dev.mysql.com/downloads/repo/apt/.
When you browse this URL, it will take you directly on the download
page from where you will download ‘mysql-apt-config_0.8.15-1_all.deb’ ( You might get latest version hence version no may be changed )
repo configuration file. Click on the Download option.
On the next page, it will ask you either you want to register or log in. If you don’t want to select these options then, click ‘No thanks, just start my download’ link to download the required package to your system’s local directory.
Step 2: Installation of MySQL Workbench
Use the following command to add MySQL repository URLs in the apt
sources list so that you can install the software on your Ubuntu 20.04
system.
cd Downloads
sudo apt install ./mysql-apt-config_0.8.16-1_all.deb
Step 3: Update apt-cache
Update the apt cache using the following command to update the configuration URLs.
sudo apt update
Step 4: Installing MySQL Workbench on Ubuntu 20.04
Now, it’s time to install MySQL workbench using the apt repository.
To do that, execute the following command to install MySQL workbench.
sudo apt install mysql-workbench-community
Step 5: Launch MySQL Workbench
Once the installation is complete, you will finally launch the MySQL
Workbench on your system. You can launch it using the terminal by typing
the following command:
mysql-workbench
You are DONE!
But wait a minute, It is equally important to know how to uninstall MySQL and MySQL Workbenc
Uninstall MySQL
- Make sure MySQL is not running:
sudo systemctl stop mysql
- Then purge all of the MySQL packages:
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
- Then delete all of the MySQL files:
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
- Finally clean all packages that are not needed:
sudo apt autoremove
sudo apt autoclean
GitHub: https://github.com/G-Sudarshan
LinkedIn: https://www.linkedin.com/in/g-sudarshan
Twitter: https://twitter.com/g_sudarshan11
Top comments (4)
sudo apt autoremove
sudo apt autoclean
dude i am a newbie to linux, and after running these commands my nvidia drivers are gone, default apps are gone that were useful and i don't even know what has changed. now tell me what should i do?
These are safe commands. They remove obsolete stuff that's not being used. Maybe you installed something manually in a location you shouldn't have (like inside the gut of the filesystem). See this
Which laptop you are using and which OS?
I don't know if i made a mistake but installed mysql before add mysql apt repository so when i used 'apt update' it shows me there's a mysql update waiting, i decided to use 'apt upgrade' to download and install that update but bring me an error with the message these 'packages will be ignore', after try several minutes i unnistall mysql and install it again. That resolved the problem and all work properly (mysql and workbech) but phpmyadmin stop working (i don't why but someday i'll fix it). I write this if someone have the same little error.