Search code examples
mysqlapachemysql-error-2002

how to use lampp with external mysql


I have installed normal mysql with apt-get and now I need to connect it with my lampp server, when is lampp booting it echo "Another MySQL deamon already running" (of course - thats right), but when I open phpmyadmin it gives me an message

2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)

So how I could connect non-lampp mysql with lampp - I suppose that will be with a mysql socket, but I don't know how...


Solution

  • mysql listens for two seperiate types of connections, tcp and unix socket. You can view what your mysqld process listens to with the netstat command:

    # netstat -npl | grep mysql
    tcp        0      0 127.0.0.1:3306              0.0.0.0:*                   LISTEN      2059/mysqld         
    unix  2      [ ACC ]     STREAM     LISTENING     6221   2059/mysqld         /var/lib/mysql/mysql.sock
    

    Default port for tcp is 3306, and default socket is /var/lib/mysql/mysql.sock (at least it is on RHEL). Local connections (such as the mysql command) tend to use the socket, while remote connections (other servers) need to use the TCP socket.

    If your server isn't listening on one, you may have to specify them in your mysqld configuration. These values are controlled in the /etc/my.cnf file:

    [mysqld]
    socket=/var/lib/mysql/mysql.sock
    port=3306
    

    Also, if your TCP socket is listening on localhost only (127.0.0.1) you can specify this in the my.cnf file:

    bind_address=0.0.0.0
    

    0.0.0.0 means listen on all local interfaces. If you want it to listen on a specific IP address, specify it.