?
Solved

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

Posted on 2007-11-19
19
Medium Priority
?
303 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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

752 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