Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am having a problems connecting to my database outside of phpmyadmin.

Im pretty sure this is because my server isn't listening on port 3306.

When I type:

sudo netstat -ntlp

on my OTHER working server I can see the following line:

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      20445/mysqld 

However, this line does not appear on the server I am having difficulty with.

How do I make my sever listen for mysql connections?

Here my my.conf file:

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

[mysqld]
#
# * Basic Settings
#
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql

#skip-networking=off
#skip_networking=off


#skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 0.0.0.0
#
# * Fine Tuning
#

key_buffer              = 64M
max_allowed_packet      = 64M
thread_stack            = 650K
thread_cache_size       = 32

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10
#
# * Query Cache Configuration
#
query_cache_limit   = 2M
query_cache_size        = 32M
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# Here you can see queries with especially long duration
#log_slow_queries   = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id      = 1
#log_bin            = /var/log/mysql/mysql-bin.log
expire_logs_days    = 10
max_binlog_size         = 100M
#binlog_do_db       = include_database_name
#binlog_ignore_db   = include_database_name
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet  = 32M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer      = 32M

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
share|improve this question
    
Can you post your my.cnf file? –  Abhishek Anand Amralkar Apr 29 '13 at 12:02
    
Sure. See above... –  Bob Flemming Apr 29 '13 at 12:42
add comment

2 Answers

Make sure bind-address is set to 0.0.0.0, then make sure app armor is giving MySQL networking privileges. Check MySQL and app armor (dmesg I think) logs to see if app armor is blocking network connections.

share|improve this answer
add comment

Uncomment the below and replace 0.0.0.0 with your server Ip Address , once done with changes save the my.cnf file and restart Mysql Daemon and see if it works or not..

  #bind-address           = 0.0.0.0

it should be

  bind-address = 192.168.1.3(example replace it with your server ip address)

also you need to give proper Grant to user see below example

  GRANT ALL ON foo.* TO bar@'202.54.10.20' IDENTIFIED BY 'PASSWORD';
share|improve this answer
    
Ok, I have tried both of your suggestions but still no luck. I still dont see my server listening on port 3306. I think this is where the issue lies. I need to figure out sure how to make mysql tell the server to listen for connections. Any ideas? –  Bob Flemming Apr 29 '13 at 13:22
    
Your mysql already listening on port = 3306. try to stop apparmor service apparmor stop and see if it helps.. –  Abhishek Anand Amralkar Apr 29 '13 at 13:56
1  
No, its not listening. I think you misread my question. When I type netstat -tap | grep mysql nothing appears. How do I get it the server to listen on 3306? –  Bob Flemming Apr 29 '13 at 14:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.