Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Granting remote access to a mysql server in php

Posted on 2014-01-28
4
Medium Priority
?
465 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 35

Accepted Solution

by:
gr8gonzo earned 2000 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 35

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 35

Expert Comment

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

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

773 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