Solved

Granting remote access to a mysql server in php

Posted on 2014-01-28
4
443 Views
Last Modified: 2014-02-01
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
0
Comment
Question by:andieje
  • 3
4 Comments
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 39815095
1. Monty is the name of one of the original main guys on the MySQL team. Many of the examples in the documentation use monty as an example of a username.

2. % is a wildcard for the "from" part, so if you're granting privileges to 'andieje'@'%' , then it means that the user named andieje can connect from -ANY- IP address in the world.

3. "usr" is just another example of a username. Sounds like someone combined two different examples and didn't bother to make the username the same.
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 39815102
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.
0
 

Author Comment

by:andieje
ID: 39815354
If i wanted to allow access from just a specific ip i would just change the % to the ip address?

thanks
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 39815380
Correct or a hostname, if that works any better for your situation.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now