How to connect to your MySQL database remotely

Published on May 2, 2016 by Daniel Lanza

 ubuntu  mysql

This tutorial will explain how to connect remotely to MySQL database. In this example, MySQL server is installed in Ubuntu Server virtual machine with VirtualBox.

Requirements

Expose MySQL server

To expose MySQL to anything other than localhost you will have to expose the IP address. Find bind-address in /etc/mysql/my.cnf and assigned to your computers IP address.

sudo vim /etc/mysql/my.cnf

Place your IP in /etc/mysql/my.cnf file.

bind-address = 192.168.56.101

Restart MySQL to apply changes.

sudo service mysql restart

Granting access

For a remote user to connect with the correct privileges, you need to have that user created in both the localhost and ‘%’ as in.

Login to your MySQL server.

mysql -u root -p

Make sure the service user for your application is both localhost and ‘%’.

CREATE USER 'mybbuser'@'localhost' IDENTIFIED BY 'password';
CREATE USER 'mybbuser'@'%' IDENTIFIED BY 'password';

then, grant privileges on the MySQL database (database name: mybb).

GRANT ALL ON mybb.* TO 'mybbuser'@'localhost';
GRANT ALL ON mybb.* TO 'mybbuser'@'%';

and finally,

FLUSH PRIVILEGES;
EXIT;

MySQL client

Open Toad application, and filled up your database parameters.

Test your connection and manage your database with your MySQL client.

Test connection
Test connection
MySQL database with Toad
MySQL database with Toad
comments powered by Disqus

See also

Install MyBB on Ubuntu Server

This tutorial will explain how to install MyBB in Ubuntu Server. Requirements A Ubuntu Server virtual machine with: MySQL Apache FTP Samba Check out these posts to get ready: How to install Ubuntu Server on VirtualBox Setting up a Virtual Web Server with VirtualBox, Apache, MySQL, FTP, Ubuntu, and Samba Our virtual machine has two network adapters. The second one (eth1) is a host-only adapter with a static IP address -> 192.

Read more

Setting up a Virtual Web Server with VirtualBox, Apache, MySQL, FTP, Ubuntu, and Samba

This tutorial will explain how to set up a Ubuntu Server virtual machine with: Apache FTP Samba First, check out how to install Ubuntu Server on VirtualBox to get ready a virtual machine to test. Our virtual machine has two network adapters. The second one (eth1) is a host-only adapter with a static IP address -> 192.168.56.101 Apache Web Server Apache Web Server needs to be running. The installation and configuration was indicated in the previous post.

Read more

Install Ubuntu Server 14.04.4 on VirtualBox

This tutorial will explain how to install Ubuntu Server on a virtual machine. First, you need to have Ubuntu Server ISO file and VirtualBox installed. VirtualBox Ubuntu Server Create a new virtual machine on VirtualBox by clicking on New. Create new virtual machine Select type and version of the virtual machine. In this case, Linux and Ubuntu (64-bits). Select type and version of the virtual machine Select the amount of memory (RAM).

Read more