Professional Web Applications Themes

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects - MySQL

Hello All I'm new to Linux and am trying to learn to develop PHP and MySQL web applications but am stuck. I'm running Suse 10.0 and have installed Apache, PHP and MySQL from the DVD. Apache, and PHP are working and <?php phpinfo(); ?> produces the expected output. MySQL is also working and I've used knoda to create a sample database. I'm using this php to try to connect to MySQL $mysqluser = 'root'; $mysqlpasswd = 'mypassword123'; $mysqlhost = 'localhost'; $connID = mysql_connect($mysqlhost, $mysqluser, $mysqlpasswd); However, when I try it I get: Can't connect to local MySQL server through socket ...

  1. #1

    Default Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

    Hello All


    I'm new to Linux and am trying to learn to develop PHP and MySQL web
    applications but am stuck.


    I'm running Suse 10.0 and have installed Apache, PHP and MySQL from
    the DVD.


    Apache, and PHP are working and <?php phpinfo(); ?> produces the
    expected output.


    MySQL is also working and I've used knoda to create a sample
    database.


    I'm using this php to try to connect to MySQL


    $mysqluser = 'root';
    $mysqlpasswd = 'mypassword123';
    $mysqlhost = 'localhost';
    $connID = mysql_connect($mysqlhost, $mysqluser, $mysqlpasswd);


    However, when I try it I get:


    Can't connect to local MySQL server through socket '/var/lib/mysql/
    mysql.sock' (13) .


    I've been searching the posts and understand that 13 means it is a
    permissions problem. However all the reported causes I can find seem
    OK on my machine.


    1) MySQL is running
    I've checked with mysqladmin ping and get the following


    linux:~ # mysqladmin -p ping
    Enter password:
    mysqld is alive
    linux:~ #


    2) SELinux is disabled


    I used usr/sbin/setenforce Permissive and now /usr/sbin/getenforce
    says 'Disabled'


    linux:~ #


    3) mysql.sock is where I'd expect it to be with the expected mysql
    owner, mysql group and expected permissions. I tested this like so.


    linux:~ # ls -l /var/lib/mysql/mysql.sock
    srwxrwxrwx 1 mysql mysql 0 Jul 15 13:54 /var/lib/mysql/mysql.sock
    linux:~ #


    4) /var/lib/mysql/ has the expected mysql owner, mysql group and
    expected permissions. I tested this like so.


    5) /var/lib/mysql/ has the expected mysql owner, mysql group and
    expected permissions. I tested this like so.


    linux:~ # ls -l /var/lib/


    .......(omitting lines here)


    drwxrwxrwx 7 mysql mysql 520 Jul 15 13:54 mysql


    .......(omitting lines here)


    linux:~ #


    6) I included myself in the mysql group.


    Clearly, I am missing something but I don't know what.


    My guess is it is something silly and simple, but it beats me. Any
    help anyone can give would be greatly appreciated.

    sean.moley@gmail.com Guest

  2. #2

    Default Re: Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

    == Quote from sean.moley ( com)'s article 

    make sure the user that runs the webserver can also read the socket file. i
    believe that's the one that tries to read the socket file.
    --
    POST BY: lark with PHP News Reader
    lark Guest

  3. #3

    Default Re: Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

     


    Thanks for the reply

    Correct me if I'm wrong, but doesn't this indicate that all users have
    full access to the socket


    linux:~ # ls -l /var/lib/mysql/mysql.sock
    srwxrwxrwx 1 mysql mysql 0 Jul 15 13:54 /var/lib/mysql/mysql.sock
    linux:~ #

    I assumed this covers whatever user runs the webserver?



    sean.moley@gmail.com Guest

  4. #4

    Default Re: Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

    == Quote from sean.moley ( com)'s article [/ref]
    socket file. i 
    > Thanks for the reply
    > Correct me if I'm wrong, but doesn't this indicate that all users[/ref]
    have 

    yes, it does! now check my.cnf to see if there is a line in there
    for mysql.sock and/or its location. a lot of times, the socket file
    ends up in /tmp/mysql.sock

    --
    POST BY: lark with PHP News Reader
    lark Guest

  5. #5

    Default Re: Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

    Thanks for the reply and sorry for the delay in responding further.

    The refs to mysql.sock in my.cnf look OK also

    here they are.


    # The following options will be passed to all MySQL clients
    [client]
    #password = your_password
    port = 3306
    socket = /var/lib/mysql/mysql.sock


    # The MySQL server
    [mysqld]
    port = 3306
    socket = /var/lib/mysql/mysql.sock


    sean.moley@gmail.com Guest

  6. #6

    Default Re: Can't connect '/var/lib/mysql/mysql.sock' (13) - but not theusual suspects

    com wrote: 
    one more thing to ask: have you installed php mysql extensions? when you
    do a phpinfo(); it should list it.
    lark Guest

  7. #7

    Default Re: Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

    On 20 Jul, 15:07, lark <net> wrote:
     

    Thanks lark

    A php page with <?php phpinfo(); ?> produces a web page with this
    lot.


    PHP LogoPHP Version 4.4.0


    System Linux linux 2.6.13-15.16-default #1 Fri Jun 8 15:35:39 UTC
    2007 i686
    Build Date Jun 16 2007 00:00:45
    Configure Command './configure' '--prefix=/usr' '--datadir=/usr/
    share/php' '--mandir=/usr/share/man' '--bindir=/usr/bin' '--libdir=/
    usr/share' '--includedir=/usr/include' '--sysconfdir=/etc' '--with-
    _lib=lib' '--with-config-file-path=/etc' '--with-exec-dir=/usr/lib/php/
    bin' '--disable-debug' '--enable-inline-optimization' '--enable-memory-
    limit' '--enable-magic-quotes' '--enable-safe-mode' '--enable-
    sigchild' '--disable-ctype' '--disable-session' '--without-mysql' '--
    disable-cli' '--without-pear' '--with-openssl' '--with-apxs2=/usr/sbin/
    apxs2-prefork' 'i586-suse-linux'
    Server API Apache 2.0 Handler
    Virtual Directory Support disabled
    Configuration File (php.ini) Path /etc/php.ini
    PHP API 20020918
    PHP Extension 20020429
    Zend Extension 20050606
    Debug Build no
    Zend Memory Manager enabled
    Thread Safety disabled
    Registered PHP Streams php, http, ftp, https, ftps, compress.zlib,
    compress.bzip2


    Zend logo This program makes use of the Zend Scripting Language
    Engine:
    Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies


    PHP Credits
    Configuration
    PHP Core
    Directive
    Local Value
    Master Value
    allow_call_time_pass_reference On On
    allow_url_fopen On On
    always_populate_raw_post_data Off Off
    arg_separator.input & &
    arg_separator.output & &
    asp_tags Off Off
    auto_append_file no value no value
    auto_prepend_file no value no value
    browscap no value no value
    default_cht no value no value
    default_mimetype text/html text/html
    define_syslog_variables Off Off
    disable_classes no value no value
    disable_functions no value no value
    display_errors On On
    display_startup_errors Off Off
    doc_root no value no value
    docref_ext no value no value
    docref_root no value no value
    enable_dl On On
    error_append_string no value no value
    error_log no value no value
    error_prepend_string no value no value
    error_reporting 2039 2039
    expose_php On On
    extension_dir /usr/lib/php/extensions /usr/lib/php/extensions
    file_uploads On On
    gpc_order GPC GPC
    highlight.bg #FFFFFF #FFFFFF
    highlight.comment #FF8000 #FF8000
    highlight.default #0000BB #0000BB
    highlight.html #000000 #000000
    highlight.keyword #007700 #007700
    highlight.string #DD0000 #DD0000
    html_errors On On
    ignore_repeated_errors Off Off
    ignore_repeated_source Off Off
    ignore_user_abort Off Off
    implicit_flush Off Off
    include_path /usr/share/php /usr/share/php
    log_errors Off Off
    log_errors_max_len 1024 1024
    magic_quotes_gpc On On
    magic_quotes_runtime Off Off
    magic_quotes_sybase Off Off
    max_execution_time 30 30
    max_input_nesting_level 64 64
    max_input_time 60 60
    memory_limit 8M 8M
    open_basedir no value no value
    output_buffering no value no value
    output_handler no value no value
    post_max_size 16M 16M
    precision 12 12
    register_argc_argv On On
    register_globals Off Off
    report_memleaks On On
    safe_mode Off Off
    safe_mode_exec_dir no value no value
    safe_mode_gid Off Off
    safe_mode_include_dir no value no value
    sendmail_from no value no value
    sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
    serialize_precision 100 100
    short_open_tag On On
    SMTP localhost localhost
    smtp_port 25 25
    sql.safe_mode Off Off
    track_errors Off Off
    unserialize_callback_func no value no value
    upload_max_filesize 16M 16M
    upload_tmp_dir no value no value
    user_dir no value no value
    variables_order EGPCS EGPCS
    xmlrpc_error_number 0 0
    xmlrpc_errors Off Off
    y2k_compliance On On


    apache2handler
    Apache Version Apache/2.0.54 (Linux/SUSE)
    Apache API Version 20020903
    Server Administrator [no address given]
    Hostname:Port linux.site:0
    User/Group wwwrun(30)/8
    Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection:
    100
    Timeouts Connection: 300 - Keep-Alive: 15
    Virtual Server No
    Server Root /srv/www
    Loaded Modules core prefork http_core mod_so mod_access
    mod_actions mod_alias mod_auth mod_auth_dbm mod_autoindex mod_cgi
    mod_dir mod_env mod_expires mod_include mod_log_config mod_mime
    mod_negotiation mod_setenvif mod_ssl mod_suexec mod_userdir
    sapi_apache2


    Directive
    Local Value
    Master Value
    engine 1 1
    last_modified 0 0
    xbithack 0 0


    Apache Environment
    Variable
    Value
    HTTP_CONNECTION Keep-Alive
    HTTP_USER_AGENT Mozilla/5.0 (compatible; Konqueror/3.4; Linux)
    KHTML/3.4.2 (like Gecko)
    HTTP_ACCEPT text/html, image/jpeg, image/png, text/*, image/*, */
    *
    HTTP_ACCEPT_ENCODING x-gzip, x-deflate, gzip, deflate
    HTTP_ACCEPT_CHT utf-8, utf-8;q=0.5, *;q=0.5
    HTTP_ACCEPT_LANGUAGE en
    HTTP_HOST localhost
    PATH /sbin:/usr/sbin:/bin:/usr/bin:/lib/klibc/bin
    SERVER_SIGNATURE <address>Apache/2.0.54 (Linux/SUSE) Server at
    localhost Port 80</address>
    SERVER_SOFTWARE Apache/2.0.54 (Linux/SUSE)
    SERVER_NAME localhost
    SERVER_ADDR ::1
    SERVER_PORT 80
    REMOTE_ADDR ::1
    DOENT_ROOT /srv/www/htdocs
    SERVER_ADMIN [no address given]
    SCRIPT_FILENAME /home/sean.moley/public_html/information.php
    REMOTE_PORT 20499
    GATEWAY_INTERFACE CGI/1.1
    SERVER_PROTOCOL HTTP/1.1
    REQUEST_METHOD GET
    QUERY_STRING no value
    REQUEST_URI /~sean.moley/information.php
    SCRIPT_NAME /~sean.moley/information.php


    HTTP Headers Information
    HTTP Request Headers
    HTTP Request GET /~sean.moley/information.php HTTP/1.1
    Connection Keep-Alive
    User-Agent Mozilla/5.0 (compatible; Konqueror/3.4; Linux) KHTML/
    3.4.2 (like Gecko)
    Accept text/html, image/jpeg, image/png, text/*, image/*, */*
    Accept-Encoding x-gzip, x-deflate, gzip, deflate
    Accept-Cht utf-8, utf-8;q=0.5, *;q=0.5
    Accept-Language en
    Host localhost
    HTTP Response Headers
    X-Powered-By PHP/4.4.0
    Keep-Alive timeout=15, max=100
    Connection Keep-Alive
    Transfer-Encoding chunked
    Content-Type text/html


    bz2
    BZip2 Support Enabled
    BZip2 Version 1.0.3, 15-Feb-2005


    gd
    GD Support enabled
    GD Version bundled (2.0.28 compatible)
    FreeType Support enabled
    FreeType Linkage with freetype
    T1Lib Support enabled
    GIF Read Support enabled
    GIF Create Support enabled
    JPG Support enabled
    PNG Support enabled
    WBMP Support enabled
    XBM Support enabled


    iconv
    iconv support enabled
    iconv implementation glibc
    iconv library version 2.3.5


    Directive
    Local Value
    Master Value
    iconv.input_encoding ISO-8859-1 ISO-8859-1
    iconv.internal_encoding ISO-8859-1 ISO-8859-1
    iconv.output_encoding ISO-8859-1 ISO-8859-1


    mcrypt
    mcrypt support
    enabled
    version >= 2.4.x
    Supported ciphers cast-128 gost rijndael-128 twofish arcfour
    cast-256 loki97 rijndael-192 saferplus wake fish-compat des
    rijndael-256 serpent xtea fish enigma rc2 tripledes
    Supported modes cbc cfb ctr ecb ncfb nofb ofb stream


    Directive
    Local Value
    Master Value
    mcrypt.algorithms_dir no value no value
    mcrypt.modes_dir no value no value


    mysql
    MySQL Support
    enabled
    Active Persistent Links 0
    Active Links 0
    Client API version 4.1.13
    MYSQL_MODULE_TYPE none
    MYSQL_SOCKET /var/lib/mysql/mysql.sock
    MYSQL_INCLUDE no value
    MYSQL_LIBS no value


    Directive
    Local Value
    Master Value
    mysql.allow_persistent Off Off
    mysql.connect_timeout 60 60
    mysql.default_host no value no value
    mysql.default_password no value no value
    mysql.default_port no value no value
    mysql.default_socket /var/lib/mysql/mysql.sock /var/lib/mysql/
    mysql.sock
    mysql.default_user no value no value
    mysql.max_links Unlimited Unlimited
    mysql.max_persistent Unlimited Unlimited
    mysql.trace_mode Off Off


    openssl
    OpenSSL support enabled
    OpenSSL Version OpenSSL 0.9.7g 11 Apr 2005


    overload
    User-Space Object Overloading Support enabled


    pcre
    PCRE (Perl Compatible Regular Expressions) Support enabled
    PCRE Library Version 5.0 13-Sep-2004


    posix
    Revision $Revision: 1.51.2.4 $


    session
    Session Support enabled
    Registered save handlers files user


    Directive
    Local Value
    Master Value
    session.auto_start Off Off
    session.bug_compat_42 On On
    session.bug_compat_warn Off Off
    session.cache_expire 180 180
    session.cache_limiter nocache nocache
    session.cookie_domain no value no value
    session.cookie_lifetime 0 0
    session.cookie_path / /
    session.cookie_secure Off Off
    session.entropy_file no value no value
    session.entropy_length 0 0
    session.gc_divisor 100 100
    session.gc_maxlifetime 1440 1440
    session.gc_probability 1 1
    session.name PHPSESSID PHPSESSID
    session.referer_check no value no value
    session.save_handler files files
    session.save_path /var/lib/php /var/lib/php
    session.serialize_handler php php
    session.use_cookies On On
    session.use_only_cookies Off Off
    session.use_trans_sid Off Off


    standard
    Regex Library Bundled library enabled
    Dynamic Library Support enabled
    Path to sendmail /usr/sbin/sendmail -t -i


    Directive
    Local Value
    Master Value
    assert.active 1 1
    assert.bail 0 0
    assert.callback no value no value
    assert.quiet_eval 0 0
    assert.warning 1 1
    auto_detect_line_endings 0 0
    default_socket_timeout 60 60
    safe_mode_allowed_env_vars PHP_ PHP_
    safe_mode_protected_env_vars LD_LIBRARY_PATH LD_LIBRARY_PATH
    url_rewriter.tags
    a=href,area=href,frame=src,input=src,form=,fieldse t=
    a=href,area=href,frame=src,input=src,form=,fieldse t=
    user_agent no value no value


    tokenizer
    Tokenizer Support enabled


    xml
    XML Support active
    XML Namespace Support active
    EXPAT Version 1.95.6


    zlib
    ZLib Support enabled
    Compiled Version 1.2.3
    Linked Version 1.2.3


    Directive
    Local Value
    Master Value
    zlib.output_compression Off Off
    zlib.output_compression_level -1 -1
    zlib.output_handler no value no value


    Additional Modules
    Module Name


    Environment
    Variable
    Value
    CONSOLE /dev/console
    ROOTFS_FSTYPE reiserfs
    TERM linux
    SHELL /bin/sh
    PROFILE default
    ROOTFS_FSCK 0
    get_module_list_done true
    LC_ALL POSIX
    INIT_VERSION sysvinit-2.85
    REDIRECT /dev/tty1
    COLUMNS 158
    get_includes_done true
    PATH /sbin:/usr/sbin:/bin:/usr/bin:/lib/klibc/bin
    vga 0x31a
    RUNLEVEL 5
    PWD /
    SPLASHCFG /etc/bootsplash/themes/SuSE/config/
    bootsplash-1280x1024.cfg
    PREVLEVEL N
    LINES 59
    HOME /
    SHLVL 2
    splash silent
    SPLASH yes
    ROOTFS_BLKDEV /dev/sda6
    _ /sbin/startproc
    DAEMON /usr/sbin/httpd2-prefork


    PHP Variables
    Variable
    Value
    _SERVER["HTTP_CONNECTION"] Keep-Alive
    _SERVER["HTTP_USER_AGENT"] Mozilla/5.0 (compatible; Konqueror/3.4;
    Linux) KHTML/3.4.2 (like Gecko)
    _SERVER["HTTP_ACCEPT"] text/html, image/jpeg, image/png, text/*,
    image/*, */*
    _SERVER["HTTP_ACCEPT_ENCODING"] x-gzip, x-deflate, gzip, deflate
    _SERVER["HTTP_ACCEPT_CHT"] utf-8, utf-8;q=0.5, *;q=0.5
    _SERVER["HTTP_ACCEPT_LANGUAGE"] en
    _SERVER["HTTP_HOST"] localhost
    _SERVER["PATH"] /sbin:/usr/sbin:/bin:/usr/bin:/lib/klibc/bin
    _SERVER["SERVER_SIGNATURE"] <address>Apache/2.0.54 (Linux/SUSE)
    Server at localhost Port 80</address>
    _SERVER["SERVER_SOFTWARE"] Apache/2.0.54 (Linux/SUSE)
    _SERVER["SERVER_NAME"] localhost
    _SERVER["SERVER_ADDR"] ::1
    _SERVER["SERVER_PORT"] 80
    _SERVER["REMOTE_ADDR"] ::1
    _SERVER["DOENT_ROOT"] /srv/www/htdocs
    _SERVER["SERVER_ADMIN"] [no address given]
    _SERVER["SCRIPT_FILENAME"] /home/sean.moley/public_html/
    information.php
    _SERVER["REMOTE_PORT"] 20499
    _SERVER["GATEWAY_INTERFACE"] CGI/1.1
    _SERVER["SERVER_PROTOCOL"] HTTP/1.1
    _SERVER["REQUEST_METHOD"] GET
    _SERVER["QUERY_STRING"] no value
    _SERVER["REQUEST_URI"] /~sean.moley/information.php
    _SERVER["SCRIPT_NAME"] /~sean.moley/information.php
    _SERVER["PHP_SELF"] /~sean.moley/information.php
    _SERVER["PATH_TRANSLATED"] /home/sean.moley/public_html/
    information.php
    _SERVER["argv"]
    Array
    _SERVER["argc"] 0
    _ENV["CONSOLE"] /dev/console
    _ENV["ROOTFS_FSTYPE"] reiserfs
    _ENV["TERM"] linux
    _ENV["SHELL"] /bin/sh
    _ENV["PROFILE"] default
    _ENV["ROOTFS_FSCK"] 0
    _ENV["get_module_list_done"] true
    _ENV["LC_ALL"] POSIX
    _ENV["INIT_VERSION"] sysvinit-2.85
    _ENV["REDIRECT"] /dev/tty1
    _ENV["COLUMNS"] 158
    _ENV["get_includes_done"] true
    _ENV["PATH"] /sbin:/usr/sbin:/bin:/usr/bin:/lib/klibc/bin
    _ENV["vga"] 0x31a
    _ENV["RUNLEVEL"] 5
    _ENV["PWD"] /
    _ENV["SPLASHCFG"] /etc/bootsplash/themes/SuSE/config/
    bootsplash-1280x1024.cfg
    _ENV["PREVLEVEL"] N
    _ENV["LINES"] 59
    _ENV["HOME"] /
    _ENV["SHLVL"] 2
    _ENV["splash"] silent
    _ENV["SPLASH"] yes
    _ENV["ROOTFS_BLKDEV"] /dev/sda6
    _ENV["_"] /sbin/startproc
    _ENV["DAEMON"] /usr/sbin/httpd2-prefork


    PHP License
    This program is free software; you can redistribute it and/or modify
    it under the terms of the PHP License as published by the PHP Group
    and included in the distribution in the file: LICENSE
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    If you did not receive a copy of the PHP license, or have any
    questions about PHP licensing, please contact net.


    sean.moley@gmail.com Guest

  8. #8

    Default Re: Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

    On Jul 21, 9:49 am, com wrote: 
    Hi Lark

    I'm stumped on this one and so I installed Fedora 7 and followed these
    instructions.


    http://www.flmnh.ufl.edu/linux/install_apache.htm

    It worked first time, so I'm working on Fedora for now and will come
    back to Suse when I understand stuff better.


    Thanks for your time


    sean.moley@gmail.com Guest

Similar Threads

  1. Replies: 0
    Last Post: January 29th, 02:03 PM
  2. Replies: 7
    Last Post: June 12th, 07:43 AM
  3. Replies: 1
    Last Post: January 27th, 02:49 AM
  4. Replies: 0
    Last Post: January 24th, 10:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139