Solved

How do I configure my server to use "db1.webaddress.com" instead of "localhost"

Posted on 2007-11-19
19
298 Views
Last Modified: 2013-12-16
How do I configure mysql to be accessed from a web address instead of only from localhost?
0
Comment
Question by:amakaram
[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
  • 8
  • 4
  • 3
  • +1
19 Comments
 
LVL 15

Expert Comment

by:babuno5
ID: 20311625
add an entry in
if linux
/etc/hosts
or for windows
C:\WINDOWS\system32\drivers\etc\hosts


Just add an entry there

127.0.0.1 db1.webaddress.com
0
 

Author Comment

by:amakaram
ID: 20311650
127.0.0.1 being my server ip address?  

Does it matter what "db1" is?



0
 
LVL 15

Expert Comment

by:babuno5
ID: 20311656
127.0.0.1 being my server ip address?  
172.0.0.1 means the same machine where you are accessing it

Does it matter what "db1" is?
No if you using only localhost
0
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 

Author Comment

by:amakaram
ID: 20311663
Sounds good, will try and advise.
0
 
LVL 14

Expert Comment

by:ygoutham
ID: 20312034
you dont do it that way

you use the grant command on mysql command prompt to grant the rights to all users from different hosts

GRANT ALL ON database_name.* to "user"@"%" identified by password "secret";

this adds an entry in the mysql.users table with the appropriate rights and then if you do

netstat -an | grep 3306

you would see that the server is listening on all the interfaces (including the static ip address) which can be used by any other program to access the mysql tables from a remote location.
0
 

Author Comment

by:amakaram
ID: 20312098
oh, I'm not looking to use "db1.webaddress.com" instead of "localhost" on the same server, I'm looking to connect to this server's mysql from another server.

Content in my "hosts" file:

127.0.0.1  GXXXXHOST.prod.phx1.sXXXXXr.net GXXXXHOST localhost localhost.localdomain db1.gXXXXhost.com

I added the db1... at the end of that same line.

Got this error:
Warning: mysql_connect(): Unknown MySQL server host 'db1.gXXXXhost.com' (1) in /home/content/XXXX/html/testing/connect.php on line 9
Could not connect: Unknown MySQL server host 'db1.gXXXXhost.com' (1)

Any thoughts?
0
 

Author Comment

by:amakaram
ID: 20312296
ygoutham:

Im willing to give that a try, however, I do need a little more detail.

Im not sure where the mysql command prompt is.

I have putty open and I am connected to the server from there.  Am I in the right location?
0
 

Author Comment

by:amakaram
ID: 20315354
babuno5:

That has not yelded any success.

I have run a short scipt from another server and cannot connect.
0
 
LVL 14

Expert Comment

by:ygoutham
ID: 20317818
when you are in the putty screen on the command prompt do a

mysql -u root -p

that should take you to mysql command prompt which looks like

mysql>

from where you can run the grant command
0
 
LVL 15

Expert Comment

by:babuno5
ID: 20317928
yes as i had mentioned it will work only on localhost

>>I have run a short scipt from another server and cannot connect.

But from another server it will not work

If you want to connect from outside then you need to buy a domain name that points to that server  and follow what @ygoutham said in his earlier post
0
 

Author Comment

by:amakaram
ID: 20537310
Sorry for the delay, but would like to follow up with this now that I have some time again.

ygoutham:

Lets just make sure Im following you here.

If my server A url is "http://www.webaddress.com", static ip of 166.123.456.789
which has a mysql database called "thedatabase123"
and accessible through myphpadmin with credentials of "theuser456", "thepass789",
and want to create: "db1.webaddress.com",
accessible from Server B, "http://www.anyotherdomain.com" (or any other server)...

I log onto the server, type "mysql -u root -p" which gives me "mysql>".

I then type exactly this (with quotes etc):

GRANT ALL ON thedatabase123.* to "theuser456"@"%" identified by password "thepass789";

Then I can go to Server B and create a php file with this:
$db = mysql_connect("db1.webaddress.com", "theuser456", "thepass789");
or
$db = mysql_connect("166.123.456.789", "theuser456", "thepass789");

Is this correct?

Thanks again.
0
 
LVL 14

Accepted Solution

by:
ygoutham earned 500 total points
ID: 20539780
that is completely correct

however, if for some reason it would not work then you can always add the IP address of the machine B that you are trying to access it from.  

GRANT ALL ON thedatabase123.* to "theuser456"@"SERVER_B.IP.ADDRESS.HERE" identified by password "thepass789";

also see that mysql port is open and listening on all interfaces

netstat -an | grep 3306

should show that it is listening on

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN

if you get 127.0.0.1:3306 then it means that the daemon is listening only on the localhost and not for external client machines
0
 

Author Comment

by:amakaram
ID: 20544302
Hey guys,

Ok, I logged onto that hosting account (/bin/bash) and the server root and server root with su in these examples, none with success.

[ONE]
using "root" would not allow me access in any of the server logins

[TWO]
using the user name as in "theuser456@localhost", I was able to get to MYSQL>
[THREE]
...but tried both the examples with, and without "%" both with access denied.

Any ideas?
(ONE)
mysql -u root -p
ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)
----------------------
(TWO)
mysql -u theuser456 -p
 
mysql> GRANT ALL ON thedatabase123.* to "theuser456"@"%" identified by password "thepass789";
ERROR 1044: Access denied for user: 'theuser456@localhost' to database 'thedatabase123'
 
(THREE)
mysql> GRANT ALL ON thedatabase123.* to "theuser456"@"XX.XXX.XX.XX" identified by password "thepass789";
ERROR 1044: Access denied for user: 'theuser456@localhost' to database 'thedatabase123'
mysql>

Open in new window

0
 
LVL 14

Expert Comment

by:ygoutham
ID: 20546825
obviously the user "theuser456" is not permitted to give rights to himself using this way.  you need to have root access to be granting rights to any of the other users.  have you forgotten the root password

then do the following to change the root password

http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html


0
 

Author Comment

by:amakaram
ID: 20714080
This is not abandoned. I'm trying to gain access. Just really busy with other work.  Sorry for the delay.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21133314
Forced accept.

Computer101
EE Admin
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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

726 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