LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-21-2010, 10:07 AM   #1
gtludwig
Member
 
Registered: Oct 2005
Location: Ireland
Distribution: Slackware64-current
Posts: 229

Rep: Reputation: 17
how to allow access to mysqld from localhost?


I need to test an application on a Ubuntu Server that works as a database server for the network.

On this server's /etc/mysql/my.cnf, I have:
Code:
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = <server-ip-address>
This means that I can't access the mysql server from 127.0.0.1, right?

I tried adding the following entry to /etc/hosts.allow :

Code:
mysqld : 127.0.0.1 : allow
I feel like I need to restart the service that reads /etc/hosts.allow, is this approach correct?

Or on /etc/mysql/my.cnf I can have two (or more) bind-addresses entries?

Thanks in advance,
gtludwig
 
Old 09-21-2010, 10:18 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,375

Rep: Reputation: 403Reputation: 403Reputation: 403Reputation: 403Reputation: 403
Hi

The bind-address which of ip's that belong to the server the mysql server will listen on. For example:

bind-address = <servers ip address>
Means you can't connect to localhost. If you want access to it from the server itself, you need to specify that external ip address when you connect. There usually is no point setting it this way.

bind-address = 127.0.0.1
Then only localhost is allowed. Since other servers can't connect to the server's localhost, this is safe and usually default

bind-address = 0.0.0.0
Mysql listens on all the ip addresses of the server so anyone can connect. This is not so secure, so you usually need firewall blocking so the database is not accessible from anywhere.
 
1 members found this post helpful.
Old 09-21-2010, 10:24 AM   #3
leejohnli
Member
 
Registered: Sep 2010
Posts: 66

Rep: Reputation: 2
try : mysql -u <user> -p -h localhost
see if you can connect to the localhost
 
Old 09-21-2010, 11:07 AM   #4
gtludwig
Member
 
Registered: Oct 2005
Location: Ireland
Distribution: Slackware64-current
Posts: 229

Original Poster
Rep: Reputation: 17
leejohnli,
It connects with:
$ mysql -u root -p -h localhost

Guttorm,
I too prefer using the altenative:
bind-address = 127.0.0.1

But it wasn't me who installed this server...
 
Old 09-21-2010, 11:45 AM   #5
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,375

Rep: Reputation: 403Reputation: 403Reputation: 403Reputation: 403Reputation: 403
You can't have more than one bind-address. But if the server doesn't have more than one IP, it's no less secure to use 0.0.0.0. If the server has many, and you only want access to one of them, you can either change it to 0.0.0.0 and add some firewall rules, or you can use sockets to connect from the server itself. In my.cnf you can add a [client] section like this:

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

Replace the path to the socket with a proper one. It might be in the [mysqld] section already.
 
Old 09-24-2010, 09:42 AM   #6
gtludwig
Member
 
Registered: Oct 2005
Location: Ireland
Distribution: Slackware64-current
Posts: 229

Original Poster
Rep: Reputation: 17
Guys,

Thanks for the help! I got it working! I lacked permissions on MySQL to access the database from localhost. All was fine after I issued:
Code:
mysql> GRANT ALL PRIVILEGES ON database.* TO '<account>'@'localhost' IDENTIFIED BY '<password>';
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] MySQL Start Problem::::socket '/var/run/mysqld/mysqld.sock' (2) arun-linux Linux - Software 6 11-29-2012 06:56 AM
[SOLVED] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' Burningmace Linux - Server 5 09-06-2012 01:29 AM
How to access localhost ...... thomas2004ch Linux - Newbie 3 10-20-2009 09:06 AM
cannot access localhost Rick809 Linux - Networking 3 08-02-2006 11:27 AM
Not getting Localhost access for CUPS JaseP Linux - Networking 3 12-16-2002 12:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration