The objective is to install MySQL client or MySQL server on Ubuntu 18.04 Bionic Beaver Linux.

Operating System and Software Versions

  • Operating System: - Ubuntu 18.04 Bionic Beaver
  • Software: - MySQL 5.7


Privileged access to your Ubuntu System as root or via sudo command is required.




  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - requires given linux commands to be executed as a regular non-privileged user


Install MySQL client on Ubuntu

If you only wish to connect to MySQL server remotely but missing the mysql command you can install it my executing:
$ sudo apt install mysql-client
Confirm the correct installation by retrieving MySQL client's version number:
$ mysql -V
mysql  Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using  EditLine wrapper
To connect remotely to a MySQL server use the following syntax:

Install MySQL Server on Ubuntu

The following linux command will install MySQL server on your Ubuntu 18.04 Bionic Beaver host:
$ sudo apt install mysql-server
Before going live make sure to secure your MySQL installation by executing:
$ sudo mysql_secure_installation
If you wish to connect to your MySQL server remotely using MySQL client edit the /etc/mysql/mysql.conf.d/mysqld.cnf configuration:
$ sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
and change the bind-address
bind-address            =
bind-address            =
Once ready, reboot your MySQL server:
$ sudo service mysql restart

MySQL server should now be listening on port 3306 on all interfaces
$ ss -ltn
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port
LISTEN      0      80        * 
LISTEN      0      128        *
LISTEN      0      128          *            
LISTEN      0      128          [::]:5355                     [::]:*                  
LISTEN      0      128          [::]:22                       [::]:*                
LISTEN      0      128         [::1]:6010                     [::]:*                  
LISTEN      0      128         [::1]:6011                     [::]:*
In case you are running the ufw firewall the following linux command will allow TCP incoming traffic from any source to your Tomcat 8 server's port 3306:
$ sudo ufw allow from any to any port 3306 proto tcp
If you wish to make your firewall rules more strict visit our How to Open/Allow incoming firewall port guide for more information.