The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySQL Connection Error

Discussion in 'General Discussion' started by patchwork, May 9, 2014.

  1. patchwork

    patchwork Well-Known Member

    Joined:
    Nov 2, 2001
    Messages:
    92
    Likes Received:
    0
    Trophy Points:
    16
    I have a different php script running via a cron and it is giving the following error
    The only way I could get the script to work was to enable "Normal Shell" in the WHM->Manage Shell Access


    Pete
     
  2. cPanelPeter

    cPanelPeter Technical Analyst III
    Staff Member

    Joined:
    Sep 23, 2013
    Messages:
    569
    Likes Received:
    15
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Twitter:
    Re: All of a sudden...etc/cron.hourly/modsecparse.pl:DBI connect('modsec:localhost','modsec',...) fa

    Hello,

    The error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock can be because you don't have a mysql.sock file in /var/lib/mysql (which should be symlinked to /var/tmp or /tmp). Please post the output of your /etc/my.cnf file.
     
  3. patchwork

    patchwork Well-Known Member

    Joined:
    Nov 2, 2001
    Messages:
    92
    Likes Received:
    0
    Trophy Points:
    16
    Re: All of a sudden...etc/cron.hourly/modsecparse.pl:DBI connect('modsec:localhost','modsec',...) fa


    I have the mysql data directory on its own drive /mysql and var/lib/mysql symlinked to /mysql/mysql

    This is what I have in the my.cnf

    Code:
    # The following options will be passed to all MySQL clients
    [client]
    #password	= your_password
    port		= 3306
    socket		= /tmp/mysql.sock
    
    # Here follows entries for some specific programs
    
    # The MySQL server
    [mysqld]
    port		= 3306
    socket		= /tmp/mysql.sock
    skip-external-locking
    key_buffer_size = 196M
    max_allowed_packet = 16M
    ##datadir=/mysql/mysql
    
    max_connections = 700
    sort_buffer_size = 4M
    read_buffer_size = 2M
    read_rnd_buffer_size = 6M
    myisam_sort_buffer_size = 64M
    thread_cache_size = 8
    query_cache_size= 128M
    local-infile=0
    
    ## table_open_cache increased from 756, tmp_table_size and max_heap_table_size added
    table_open_cache = 1424
    tmp_table_size = 250M
    max_heap_table_size = 250M
    
    # Try number of CPU's*2 for thread_concurrency
    thread_concurrency = 8
    
    # Don't listen on a TCP/IP port at all. This can be a security enhancement,
    # if all processes that need to connect to mysqld run on the same host.
    # All interaction with mysqld must be made via Unix sockets or named pipes.
    # Note that using this option without enabling named pipes on Windows
    # (via the "enable-named-pipe" option) will render mysqld useless!
    # 
    #skip-networking
    
    # Replication Master Server (default)
    # binary logging is required for replication
    #log-bin=mysql-bin
    
    # binary logging format - mixed recommended
    binlog_format=mixed
    
    # required unique id between 1 and 2^32 - 1
    # defaults to 1 if master-host is not set
    # but will not function as a master if omitted
    server-id	= 1
    
    [mysqldump]
    quick
    max_allowed_packet = 16M
    
    [mysql]
    no-auto-rehash
    # Remove the next comment character if you are not familiar with SQL
    #safe-updates
    
    [myisamchk]
    key_buffer_size = 128M
    sort_buffer_size = 128M
    read_buffer = 2M
    write_buffer = 2M
    
    [mysqlhotcopy]
    interactive-timeout
    
    Code:
    [/var/lib]# ls -alih
    58196966 lrwxrwxrwx   1 root    root      12 May  9 00:00 mysql -> /mysql/mysql/
    
    Code:
     [/var/lib/mysql]# ls -alih
    2097553 lrwxrwxrwx  1 root  root    23 May  9 00:27 mysql.sock -> ../../../tmp/mysql.sock=
    
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    672
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    You can try creating "/var/cpanel/jailshell-additional-mounts" and editing the file to include the path for the custom MySQL location.

    Thank you.
     
  5. patchwork

    patchwork Well-Known Member

    Joined:
    Nov 2, 2001
    Messages:
    92
    Likes Received:
    0
    Trophy Points:
    16
    Yes that worked even though I'm not using any jailing or SU type php modules.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    672
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Yes, account cron jobs are run with jailshell automatically unless normal shell access is granted to the account.

    Thank you.
     
Loading...

Share This Page