How to connect to MySQL server in LAN?

2

0

Here is the technical description.

My laptop's config:

  • IP Adress:192.168.2.5
  • MySQL Server 5.0 on port 3306
  • Operating System: Ubuntu
  • The database is in this machine

My friend's laptop config:

  • IP Adress:192.168.2.4
  • MySQL Server 5.0 on port 3306
  • Operating System: Windows XP

Both are on a wireless LAN connected through a Belkin router (192.168.2.1). I put this but its not working:

url = "jdbc:mysql://192.168.2.5:3306/Database"

How can I configure things connect to this database?

waelbk

Posted 2012-05-31T11:30:58.487

Reputation:

Questions about home networks and personal computers are off-topic per the [faq] – MDMarra – 2012-05-31T12:59:43.100

Answers

1

MySQL is a TCP protocol running on port 3306 by defauly, hence there is nothing special beyond ensure that you have enabled binding to a public IP address in the /etc/my.cnf file;

port            = 3306
bind-address            = 0.0.0.0

On the client you would need to install the jdbc drivers for MySQL;

For windows XP they can be downloaded from here;
http://dev.mysql.com/downloads/connector/j/

For ubuntu, there are package version in the repository;

# aptitude search mysql | grep JDBC
p   libmysql-java                   - Java database (JDBC) driver for MySQL 

You can use any client, mysql provide a workbence tools product;
http://dev.mysql.com/downloads/workbench/5.2.html

or you can use Libreoffice and their database connection to view the tables;
http://www.libreoffice.org/features/base/

Or use a scripting language like php;
http://php.net/manual/en/book.mysql.php

or even just the command line client;

$ mysql -h192.168.2.5 -uuserXXX -e "show databases;"
+--------------------+
| Database           |
+--------------------+
| information_schema | 
| badger1             | 
| cacti              | 

Tom H

Posted 2012-05-31T11:30:58.487

Reputation: 169

thank you very much for your answer. my friend can access to my database in windows xp but my goal is to access to ** his database in ubuntu**. i have windows xp – None – 2012-05-31T13:03:23.950

how do you wish to access it?, is the database already running in Ubuntu, or do you need to install it? – Tom H – 2012-05-31T13:33:36.897

1$ mysql -u root -p Enter password:

mysql> use mysql

mysql> GRANT ALL ON . to root@'192.168.2.4' IDENTIFIED BY 'your-root-password'; mysql> FLUSH PRIVILEGES; – None – 2012-05-31T19:23:03.403

0

This might sound stupid but have you checked if your Ubuntu machine has its firewall running? That has tripped me up a few times on both Windows and Linux.

A quick check is to run: sudo iptables -L

Here is a how-to from the ubuntu site: https://help.ubuntu.com/community/IptablesHowTo

Mista Tea

Posted 2012-05-31T11:30:58.487

Reputation:

0

Have you configured remote access for your MySQL server ? If not, read this.

Jannis Alexakis

Posted 2012-05-31T11:30:58.487

Reputation: 241