hi every one. i have a vb6 application and i am using xampp as my database. it works fine when i access my database locally using the following code:

Driver={MySQL ODBC 3.51 Driver};Database=NAME_OF_MY_DATABASE;Server=localhost; Port=3306;Option=13;

but how will access xampp database stored in a remote pc in a network? thankz.

Recommended Answers

All 15 Replies

Try the following -

Driver={MySQL ODBC 3.51 Driver};Database=NAME_OF_MY_DATABASE;Server=\\10.0.0.111 (the server ip address)\thepcnamehere; Port=3306;Option=13;

Add username and password if it is required...

i tried your suggesstion but the following message appeared:

Unknown MySql server host '\\192.100.50.1\COMPUTER1'(11004)

192.100.50.2 is the server ip address and COMPUTER1 is the pcname. by the way i used a cloned computer. thankz.

Try the following...

cnDeleted.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
    & "SERVER=" & 192.100.50.1 & ";" _
    & "Port=3306;" _
    & "DATABASE=" & strDatabasename & ";" _
    & "UID=" & strServerUsername & ";" _
    & "PWD=" & strServerPassword & ";" _
    & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384

    ''If you are using MySql ODBC 5. ..., change it as well where above is at 3.51

For more connections, have a look at this link.

sorry but still not working, you may want to see my code.

Public cn As ADODB.Connection
Public rs As ADODB.Recordset

Sub main()
    Set cn = New ADODB.Connection

    cn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver}; 
    & "SERVER=192.100.50.1 _               'ip address of the remote computer
    & "Port=3306;" _                    
    & "DATABASE=" & studentinfo & ";" _    'databasename
    & "UID=" & computer1 & ";" _           'usename of the remote computer
    & "PWD=" & choey_13 & ";" _            'password of the remote computer  
    & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
    cn.Open
End Sub

it prompts a runtime error "Host '192.100.50.2' is not allowd to connect to this MySQL server"

192.100.50.2 is the ip address of the computer accessing the database on a remote computer. thankz again.

The user id (UID) is not your pc's username and password. It is the username and password that you have set up when you installed mysql. Normally user id is root with a password. If you did not specify a password, you can leave it empty.

For testing purposes as well, make sure the server firewall is switched off. If you can connect, then you know that you have to configure the firewall afterwards.

I have just tested the connection on my server with the same code (bar the ip, uid and pass), it connected fine.

just updated my code

Public cn As ADODB.Connection
Public rs As ADODB.Recordset

Sub main()
    Set cn = New ADODB.Connection
    cn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver}; _
    & "SERVER=192.100.50.1 ;" _            'ip address of the remote computer
    & "Port=3306;" _
    & "DATABASE=" & studentinfo & ";" _    'databasename
    & "UID=" & root & ";" _                'serverusername
    & "PWD=" &  & ";" _                    'serverpassword (no password)
    & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
    cn.Open
End Sub

and got the same runtime error "Host '192.100.50.2' is not allowed to connect to this MySQL server"

please review my code and post your code for my refference. by the way what to you mean by "bar the ip, uid and pass". thank you.

by the way what to you mean by "bar the ip, uid and pass". thank you.

It means - except ip, uid, pass.

Your code is perfect. Keep in mind that if you are running the code AND mysql from the same pc, the ip will be "localhost"...

It seems that you are having security issues, turn off the firewall on the server to test.

i just turned it off but i still have "Host '192.100.50.2' is not allowed to connect to this MySQL server" runtime error. does it something to do with the installation of my MySQL Driver? because i just used the typical installation.

No, not the driver. It is getting blocked connecting to the database in your root of server pc.

This link gives a good solution to solv e your problem.

i found this code on the link

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
    ->     WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
    ->     WITH GRANT OPTION;

where will i execute this? sorry i am very new to MySQL.

From cmd (command Prompt - Start, run, cmd)

i tried executing it in cmd but i got a "mysql is not recognized as an internal or external command, operable program or batch file" error.

please help me. i am getting crazy i really don't know what to do.

It seems that the client or server services was not started. In your webbrowser, type "localhost" into the address bar and enter. XAmpp wils show. click on phpMyAdmin which should open the database.

In your installed folder of xampp you will find an exe named xampp. Run the application and start MySql.

You can also set your security, users etc from the above....

If you want to know how to do this, google xampp control panel.

what did you use as a reference library? i keep geting the bad driver error

hey AndreRet. its been three years since i post this question. since i focused on ms access for the past years i didn't tried your the last solution but now that i am working on mysql i found out that the codes are totally correct and its all about setting the privileges of the database.. tnx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.