Solved

Granting remote access to a mysql server in php

Posted on 2014-01-28
4
451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 35

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 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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

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.
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

751 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