The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
Scripts / handy tips
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Newer Topic  |  Older Topic 
 Configuring MySQL to listen only on localhost
Author: Dan 
Date:   29-04-06 13:46

By default MySQL accepts connection over the LAN. I prefer to restrict it to localhost only. Starting with more recent versions of the FreeBSD MySQL port, you can do this:

$ grep mysql /etc/rc.conf
mysql_enable="YES"
mysql_args="--bind-address=127.0.0.1"

Then restart mysql:

# /usr/local/etc/rc.d/mysql-server.sh restart
Stopping mysql.
Waiting for PIDS: 90230.
Starting mysql.


Before:

# netstat -an | grep 3306
tcp4 0 0 *.3306 *.* LISTEN

After:

# netstat -an | grep 3306
tcp4 0 0 127.0.0.1.3306 *.* LISTEN


As you can see, in the after image, MySQL is listening only on 127.0.0.1 port 3306, instead of all IP addresses (i.e the internet).

--
Webmaster

Reply To This Message
 Forum List  |  Threaded View   Newer Topic  |  Older Topic 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org