Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Connect to SQL database
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Tue Apr 05, 2005 3:46 pm    Post subject: Connect to SQL database Reply with quote

I'm getting the following error when I try to set the password for my SQL database:

Code:
/usr/bin/mysqladmin -u root -h laptop password 'pass'
/usr/bin/mysqladmin: connect to server at 'laptop' failed
error: 'Host 'laptop.localnetwork' is not allowed to connect to this MySQL server'


This problem has been covered numerous times in other threads, but no one seems to have found a solution. When I try to set the password without using "-h laptop" everything works fines.

My questions is, what is the difference between using "-h laptop" and just leaving it out? I read that if you use "-h laptop" then you can establish remote connections to your database. What exactly does that mean? I only have ssh access to the server, so I definitely need remote access to my SQL database. What should I do?
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
msalerno
Veteran
Veteran


Joined: 17 Dec 2002
Posts: 1338
Location: Sweating in South Florida

PostPosted: Tue Apr 05, 2005 3:50 pm    Post subject: Reply with quote

What address does laptop resolve to?
If it resolves to any address other than 127.0.0.1 then there is the problem.

By default mysql listens on the lo 127.0.0.1 adapter. So if laptop resolves to 192.168.3.15, then your command:

/usr/bin/mysqladmin -u root -h laptop password 'pass'

might was well be

/usr/bin/mysqladmin -u root -h 192.168.3.15 password 'pass'

And would cause an error since Mysql isn't listening on that IP.
Back to top
View user's profile Send private message
tomvollerthun
Guru
Guru


Joined: 19 Mar 2005
Posts: 316

PostPosted: Tue Apr 05, 2005 3:54 pm    Post subject: Reply with quote

If you include -h laptop you basically tell mysql that you try to access it from the host laptop (which you are not allowed to). If you don't have it in your commandline, mysql (correctly) assumes that you connect from localhost (which you are allowed to).
Mysql has excellent information on their websites. Search it for user setup and user permissions and you'll find plenty of information on how to solve this properly.
_________________
Computer science is no more about computers than astronomy is about telescopes.
Dijsktra
---------------
Don't believe my "Guru" status!
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Tue Apr 05, 2005 7:42 pm    Post subject: Reply with quote

Thanks for all the replies guys.

I understand what you're saying, but now I have another question. Why would you ever want a different host than "localhost". In other words, why would you ever want to include the "-h" flag in the command?

Like I said in the post above, I'm trying to set up SQL so I can use it with my webserver. I have remoted acces (ssh) to the server. In order for me to use SQL, do I even need to set the "-h" flag, or is it enough if I only allow "localhost" to connect?

Thanks again for helping.
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
msalerno
Veteran
Veteran


Joined: 17 Dec 2002
Posts: 1338
Location: Sweating in South Florida

PostPosted: Tue Apr 05, 2005 8:42 pm    Post subject: Reply with quote

Quote:
Why would you ever want a different host than "localhost".

For a remotly hosted Mysql server. My hosting company does not give me shell access, but they give me access to the sql server. This way I can manage my databases from my system.

Quote:
do I even need to set the "-h" flag


No

tomvollerthun wrote:
If you include -h laptop you basically tell mysql that you try to access it from the host laptop (which you are not allowed to). If you don't have it in your commandline, mysql (correctly) assumes that you connect from localhost (which you are allowed to).
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Tue Apr 05, 2005 10:43 pm    Post subject: Reply with quote

One last question. I'm configuring SQL to work with my phpBB board. Is it dangerous to run SQL as root, and how do I find out the name of my database? Is there a default name? I just created the database following the installation instructions...
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Tue Apr 05, 2005 11:38 pm    Post subject: Reply with quote

Ok, I just read that the SQL root user has nothing to do with the systemwide root user. So I guess there is no problem with that. However, I still can't figure out the name of my database!

Any help?
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
msalerno
Veteran
Veteran


Joined: 17 Dec 2002
Posts: 1338
Location: Sweating in South Florida

PostPosted: Wed Apr 06, 2005 1:56 pm    Post subject: Reply with quote

To view a list of all databases:
# mysql -u root -p
mysql> show databases;

tommy_fila wrote:
However, I still can't figure out the name of my database!

If the database was created with a sql script from phpBB, chances are all you have to do is read through the docs.
Back to top
View user's profile Send private message
tommy_fila
Guru
Guru


Joined: 19 Nov 2003
Posts: 450
Location: Phoenix, AZ

PostPosted: Wed Apr 06, 2005 2:54 pm    Post subject: Reply with quote

I figured it out. Thank you!
_________________
"What goes on in life, that goes for eternity."
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum