Solved

Granting remote access to a mysql server in php

Posted on 2014-01-28
4
450 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL Finding Duplicates in a Normalized Database 6 28
Change a button after e-mail 4 19
Echo'd values in dropdowns 6 28
restriction of entering a a page 5 31
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

763 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