Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 21, 2012, 03:08:51 AM

Pages: [1]   Go Down
  Print  
Author Topic: connect to mysql from another site?  (Read 2727 times)
agrafuese
Newbie
*
Offline Offline

Posts: 5


« on: August 08, 2008, 05:32:34 PM »

hi, we just got a dedicated server and i'm wondering how i would go about connecting to the mysql server database from an outside source. for example, let's say my current site on the dedicated server is called "site1.com" and i have another site somewhere else called "site2.com", how would i make it so that site2.com connects to site1.com's mysql database?
Logged
perestrelka
Administrator
Master Jedi
*****
Offline Offline

Posts: 1395



« Reply #1 on: August 08, 2008, 10:01:54 PM »

Hi,

To allow remote connections to MySQL on your server, it is advisable to do the following steps:

1. ensure MySQL port 3306 is opened in server firewall (more than likely it is)
2. verify there is MySQL user created that is allowed to connect to the needed database from the IP where you'll be connecting from
3. specify the name or the IP of the server and login details in the connection string of the scripts on the remote site.
Logged

Kind Regards,
Vlad Artamonov
agrafuese
Newbie
*
Offline Offline

Posts: 5


« Reply #2 on: August 09, 2008, 12:20:12 PM »

Thank you for the information. When I want to set up a mysql user to have access, is this the proper command?:
Code:
GRANT ALL PRIVILEGES ON *.* TO <username>@% IDENTIFIED BY "<password>";
FLUSH PRIVILEGES

Logged
perestrelka
Administrator
Master Jedi
*****
Offline Offline

Posts: 1395



« Reply #3 on: August 09, 2008, 08:58:41 PM »


That command will create a user that will be able to connect from any IP and have all privileges to all dbs in MySQL. I would replace *.* with dbname.* to leave only access to the needed database. If you have a control panel installed on your server, it may be better to use it to create the login to the database.
Logged

Kind Regards,
Vlad Artamonov
agrafuese
Newbie
*
Offline Offline

Posts: 5


« Reply #4 on: August 10, 2008, 03:05:55 PM »

Ah, I see. We're just using the basic LunarPanel, and as far as I can tell, we can create user accounts for the DB, but I don't see anything in the control panel that allows us to assign remote access. But that's okay, and I'm fine with assigning remote access manually via SSH. So it would be better if I used this command:
Code:
GRANT ALL PRIVILEGES ON <db> TO <username>@<IP> IDENTIFIED BY "<password>";
FLUSH PRIVILEGES

Yes?

Logged
perestrelka
Administrator
Master Jedi
*****
Offline Offline

Posts: 1395



« Reply #5 on: August 13, 2008, 10:26:18 PM »

Ah, I see. We're just using the basic LunarPanel, and as far as I can tell, we can create user accounts for the DB, but I don't see anything in the control panel that allows us to assign remote access. But that's okay, and I'm fine with assigning remote access manually via SSH. So it would be better if I used this command:
Code:
GRANT ALL PRIVILEGES ON <db> TO <username>@<IP> IDENTIFIED BY "<password>";
FLUSH PRIVILEGES

Yes?


With small correction to the syntax, yes:

Code:
GRANT ALL PRIVILEGES ON <db>.* TO <username>@<IP> IDENTIFIED BY "<password>";
FLUSH PRIVILEGES
Logged

Kind Regards,
Vlad Artamonov
Pages: [1]   Go Up
  Print  
 
Jump to: