Link to home
Start Free TrialLog in
Avatar of andieje
andieje

asked on

Granting remote access to a mysql server in php

Hi

I have been reading this page on how to connect to a remote mysql server via php
The thread is pretty old

stackoverflow.com/questions/1935314/connecting-to-remote-mysql-server-using-php

I am going to follow these instructions but I dont understand this bit

create a user (usr or anything) with % as domain and grant her access to the database in question.

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

Open in new window


What is % as the domain? Who is usr? Who is monty on the second line?

thanks a lot
ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So let's say you want the user andieje, who uses the password 12345 and travels all of the world, to be able to connect to the database named ourmaindb. Again:

Username: andieje
Password: 12345
Location: From any IP (or %)
Database name: ourmaindb

mysql> CREATE USER 'andieje'@'%' IDENTIFIED BY '12345';
mysql> GRANT ALL PRIVILEGES ON ourmaindb.* TO 'andieje'@'%' WITH GRANT OPTION;

Open in new window


Bear in mind that you usually need administrator privileges to create new users and grant privileges.
Avatar of andieje
andieje

ASKER

If i wanted to allow access from just a specific ip i would just change the % to the ip address?

thanks
Correct or a hostname, if that works any better for your situation.