Solved

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

Posted on 2007-11-19
19
272 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
  • 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
 

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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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.

762 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

21 Experts available now in Live!

Get 1:1 Help Now