Results 1 to 4 of 4
  1. #1
    ahmed30 is offline Member
    Join Date
    Jan 2011
    Posts
    6
    Rep Power
    0

    Default [SOLVED]How to connect database mysql via Lan

    Hello ,

    I am creating an application that need to connect to a database server via Lan network .

    i am using mysql Wampserver 2.0 phpmyadmin as the database server.


    and i am using this code to connect but i can't connect.

    Java Code:
    String ip = "192.168.24.8";
    String port = "3306";
    String name = "database_name";
    String user = "root";
    String pass = "";
    String connection_string = "jdbc:mysql://"+ip+":"+port+"/"+name;
             
    con = DriverManager.getConnection(connection_string,user, pass);
    Can someone help me and tell me why the code does not work.

    also can i use the phpmyadmin to connect via Lan.

    i hope someone tell me some advices how to create database connections via lan

    Thank you
    Last edited by ahmed30; 01-15-2011 at 04:02 PM.

  2. #2
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    Upon insallaion of mySql on your server did you set the username root to be able to log in using other computer aside from the machine where the MySql is installed?

    Also, base on what you post your code must return an error message, kindly paste it here so we can help you more.

  3. #3
    ahmed30 is offline Member
    Join Date
    Jan 2011
    Posts
    6
    Rep Power
    0

    Default

    Well , it displays this error message :-

    " Host 'MachineName' is not allowed to connect to this MySQL server"


    or

    "Access denied for USer @ Host "


    so , i found a solution ,

    I went to phpmyadmin , Clicked on Privileges at the Top menu , created a new user with password and selected "Any Host" , and ofcourse gave him All the privileges and clicked on GO .

    Now i was able to connect through Lan with this new user.


    Thank you mine0926 for your time to help me.

    Problem SOLVED

  4. #4
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    What do you mean by 'give him(any host) all priviledges'? I think this is not
    good because of security reason. It is like letting them access your pc and do
    everything on it. What I mean in 'do everything' is to access the databases
    and tables that they should not access.

    You should set what database and tables they could only access. And what kind of DMD they can only do.

    Goodluck :)

Similar Threads

  1. Replies: 7
    Last Post: 05-09-2010, 01:25 AM
  2. Replies: 4
    Last Post: 04-28-2010, 07:13 PM
  3. Can NOT connect to Mysql
    By zed420 in forum New To Java
    Replies: 3
    Last Post: 12-18-2009, 09:26 PM
  4. Replies: 15
    Last Post: 04-15-2009, 02:51 AM
  5. Replies: 2
    Last Post: 06-12-2008, 08:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •