Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What should I do for change my connection from other network computer mysql to my computer mysql?

My computer run web application with his apache local server and mysql that located in other computer in our network. I want to connect to my local mysql instead.

(I have ubuntu 10.04 + lamp)

Thanks, Yosef

share|improve this question
up vote 1 down vote accepted

You've two machines:

  • A: the machine on which Apache resides. IP address
  • M: the machine with the MySQL database. IP address

In a default MySQL installation, MySQL listens on all interfaces and thus, other machines can reach it on it's public (network) IP address on port 3306 (default port or MySQL).

To allow A to connect with M, a MySQL account should be present on M allowing accountname@ to connect with MySQL (user = accountname). In your webapp on A, use hostname, username accountname and a password as set for accountname@

If there is a firewall on M, be sure to allow incoming connections to TCP port 3306 on M.

Assuming your webapp uses PHP as language, replace something like:

$oCon = new MySQLi('localhost', 'accountname', 'password', 'database');


$oCon = new MySQLi('', 'accountname', 'password', 'database');
share|improve this answer
Thanks, What about apache configs? – Yosef Mar 16 '11 at 12:43
There is no need to mess with the Apache configuration, unless you do not specify the host while connecting from PHP. In that case, you need to set the default hostname (mysqli.default_hostname for MySQLi; mysql.default_hostname for MySQL) to – Lekensteyn Mar 16 '11 at 12:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.