[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2007-11-19
19
Medium Priority
?
311 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
16 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 2000 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 to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 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