Remote access to MySQL



1   Overview
2   Procedure
  Related pages

1. Overview.

This document is intended for Linux developers. If you notice mistakes, write to:

If you need to access remote MySQL servers, or need to support access to local MySQL servers from remote clients, try the steps documented below. Note: This document assumes that you have superuser access on the server side.

2. Procedure.

2.1. If a MySQL server process is running on an Amazon EC2 instance, and you'd like to allow access by remote MySQL clients, you may need to add a Custom TCP Rule to the instance's EC2 Security Group. The Custom TCP Rule will need to set Port Range to the appropriate MySQL port number, which will often but not always be 3306.

2.2. On the server host, you may need to locate /etc/mysql/my.cnf or a file with a similar pathname and edit the file. Changes may include setting bind-address to and/or commenting out a skip-networking directive. If you change the file, you'll need to restart the MySQL server process.

2.3. On the server host, you may also need to perform a procedure similar to the following for each combination of host MySQL acount and external IP address that you'd like to allow.

In this procedure, ROOTPASS is the root password for the host copy of MySQL, USER is a host MySQL account name, IP is an external IP address, and PASS is the MySQL password associated with the host MySQL account in question.

$ mysql -u root -p'ROOTPASS'
mysql> use mysql;
mysql> grant all on *.* to USER@'IP' identified by 'PASS';
mysql> flush privileges;
mysql> quit;

For acknowledgments related to CSS and other code used, click here.

Linked or embedded works (software, books, articles, etc.) are presented under their own licenses.

Other unique content on this page, excluding screenshots, is distributed under the following license: C.C. Attribution NonCommercial ShareAlike 3.0. In some cases, screenshots are distributed under the same license. In other cases, the associated program's license applies.

image Valid XHTML 1.0