DEV Community

Cover image for Installing MySQL and MySQL Workbench on Linux
Dhanraj K
Dhanraj K

Posted on Originally published at Medium

Installing MySQL and MySQL Workbench on Linux

Simple Guideline on installing MySQL and Workbench on Ubuntu , Pop_OS or any Debian Linux.

Install MySQL

Update apt to ensure you get the latest packages and install mysql-server

$ sudo apt-get update
$ sudo apt-get install mysql-server

Next to setup and Configure MySQL

$ sudo mysql_secure_installation

Selecting Y ('yes') for all the setting is reasonabe.

To access MySQL

$ sudo mysql -u root -p

Install MySQL Workbench

Download the installer which is compatable for your system and Linux version .

click here to download

Just click on the deb file and install or use dpkg command to install

$ sudo dpkg -i path_to_deb_file

To Uninstall MySQL and MySQL Workbench

If u want to remove both this softwares completely from your system use the following commands

To remove MySQL

$ sudo apt-get remove --purge mysql-server mysql-client mysql-common -y
$ sudo apt-get autoremove -y
$ sudo apt-get autoclean

To remove MySQL Workbench

$ sudo apt-get remove mysql-workbench-community
or
$ sudo dpkg -r mysql-workbench-community
$ sudo dpkg --purge mysql-workbench-community

To Start, Stop, Restart or check Status of MySQL Service

$ sudo service mysql start 
$ sudo service mysql stop
$ sudo service mysql restart
$ sudo service mysql status

To Access MySQL without SUDO

When we try to access MySQL without sudo ERROR 1045 (28000): Access denied for user 'username'@'localhost' (using password: NO)

this error pops up

Follow this steps to overcome this error

$ sudo mysql  -u root -p
Enter password:
mysql> show databases;
mysql> use mysql
mysql> select user, host, plugin from mysql.user;
mysql> update user set plugin="mysql_native_password" where User="root";
mysql> flush privileges;
mysql> exit;
$ mysql -u root
mysql> SET GLOBAL validate_password.policy=LOW;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Enter_password';
mysql> exit
$ sudo service mysql restart

now we can access MySQL by using

$ mysql  -u root -p

Top comments (1)

Collapse
 
arvindsridharan profile image
arvindsridharan •

Awesome post. Most of the times it gets time to get started with mysql installation, especially with the password bit and port number.