Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Connecting to remote MySQL

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 10-12-2009
Member
 
Join Date: Nov 2009
Posts: 153
Connecting to remote MySQL
  

My problem is that I'm unable to connect to a database located in a local computer of company, that computer use wamp server (latest version).

Computer 1 has an application in vb.net and its IP address is: 192.168.1.3 and tries to connect to computer 2, which contains the database named "db1", its IP configuration is: 192.168.1.1

In my program I have in a first form, 4 TextBox:
- Server.
- User.
- Password.
- Database.

I installed wamp server on computer 1 and on the Form I typed:
Server = localhost
User = root
Password =
Database = db1

Everything goes well, I'm connected, I'm happy. After I uninstalled wamp server on computer 1. And I open my form and I typed:
Server = 192.168.1.1
User = root
Password =
Database = db1

but nothing goes well, I'm not online. I created a new user in the user table in mysql DB (computer 2) I tried connecting but ANYTHING happens. I then put % instead of localhost but NOTHING works this time. I stopped the firewall and everything is configured perfectly but all in vain. Why it does not works?

Reply With Quote
  #2  
Old 10-12-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Connecting to remote MySQL

Quote:
Originally Posted by Gavisht View Post
In my program I have in a first form, 4 TextBox:
- Server.
- User.
- Password.
- Database.

I installed wamp server on computer 1 and on the Form I typed:
Server = localhost
User = root
Password =
Database = db1

Everything goes well, I'm connected, I'm happy.
In this case you first connect to local mysql server and then run it

Quote:
Originally Posted by Gavisht View Post
After I uninstalled wamp server on computer 1. And I open my form and I typed:
Server = 192.168.1.1
User = root
Password =
Database = db1

but nothing goes well, I'm not online. I created a new user in the user table in mysql DB (computer 2) I tried connecting but ANYTHING happens. I then put % instead of localhost but NOTHING works this time. I stopped the firewall and everything is configured perfectly but all in vain. Why it does not works?
For now you wants to connect to remote server located on computer 2. Is it you who has designed the application? Your application uses native connection or not? And also check if your mysql server computer 2 permits remote connections.
Reply With Quote
  #3  
Old 10-12-2009
Member
 
Join Date: Nov 2009
Posts: 153
Re: Connecting to remote MySQL

Thank you for the reply. Yes it is me who has designed the application and I am trying to make other changes above. One of the amendments is to connect to remote mysql. Yes I use a native connection and my computer allows remote connections. I am a little confused about all this stuffs.
Reply With Quote
  #4  
Old 10-12-2009
Member
 
Join Date: Nov 2008
Posts: 1,192
Re: Connecting to remote MySQL

You will have to change your connection string stringconnection in your program on connection so you use a code for example:
Code:
try
            Dim myConnectionString As String
            myConnectionString = "Server=192.168.1.1;Database=db1; UID=root;Password= "
            Dim myConnection As New MySqlConnection(myConnectionString)
            myConnection.Open()
            Dim myselectquery As String = "SELECT * from `minichat`.`user`  WHERE `user`.`login`  = '" & cvalid_selected & "';"
            Dim myCommand As New MySqlCommand(myselectquery,
myConnection)
            Dim myready As MySqlDataReader
            myready = Nothing
            myready = myCommand.ExecuteReader()
            myready.Close()
            myConnection.Close()
        Catch ex As Exception
        End Try
and you will change the config in your wamp on editing log

You will seek 127.0.0.1 or localhost and you will replace it with 192.168.1.1
Reply With Quote
  #5  
Old 10-12-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Connecting to remote MySQL

I found your problem, you work on a root and the user root and default connects local host. Tthe solution is that you create another user

1 - open PHPMYADMIN (click on the wamp notification icon)
2 - a page opens, its the page created in the database
3 - you will click on the "Privileges"
4 - you can see the root user and these settings and can see that root travel locally
5 - you click on the link "Add User"
6 - to fill the form

Username: * you can parametrize your mysql server
It accepts the user "Any user"
Server: * select "Any Server" to allow the pc to connect that server
password: you can keep a password or let it be blank

and for the menu "Database for this user"
chose "Giving privileges passepartout ("%")"

and for "global privileges": check all preferable

click and perform

ultimately change the username and password on your connection string
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Connecting to remote MySQL"
Thread Thread Starter Forum Replies Last Post
Connecting C# with MySQL database Quattro Software Development 5 05-03-2010 10:13 PM
Issues in C# application connecting to Remote MySQL 5 database. kyosang Software Development 5 25-01-2010 04:24 PM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
Problem connecting to mysql db Wagan-rave Software Development 3 21-03-2009 10:57 AM
Connecting VB.net with mysql Jateen Software Development 1 05-01-2009 09:37 PM


All times are GMT +5.5. The time now is 08:01 AM.