1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Problem MySQL

Discussion in 'Development' started by Barry_Bradley, Aug 14, 2019.

  1. Barry_Bradley

    Barry_Bradley Spider

    Messages:
    13
    PHP:
    [16:31:12] [Server thread/CRITICAL]: ErrorException"mysqli::prepare(): MySQL s
    erver has gone away" 
    (EXCEPTIONin "plugins/BanSystemv1/src/BanSystem/Main" at
    line 135
    What the problem?

    PHP:
    public function isBanned($player){
            
    $config $this->config->get('mysqli');
            
    $name $player->getName();
            
    $ip $player->getAddress();
            
    $id $player->getClientId();

        
    $result $this->getMysqli()->query("SELECT * FROM ".$config["table"]." WHERE name = '".$name."' or ip = '".$ip."' or id = '".$id."'");
            if(!
    $result->num_rows){
                
    $result->close();
                return 
    false;
            }else{
                
    $result->close();
                return 
    true;
            }
        
        }
     
  2. Barry_Bradley

    Barry_Bradley Spider

    Messages:
    13
    Add php.ini extension=mysqli
    PHP:
    PHP Warning:  PHP StartupUnable to load dynamic library 'mysqli' (tried: /var/
    jenkins_home/workspace/PHP-7.2-Linux-x86_64/bin/php7/lib/php/extensions/no-debug
    -zts-20170718/mysqli (/var/jenkins_home/workspace/PHP-7.2-Linux-x86_64/bin/php7/
    lib/php/extensions/no-debug-zts-20170718/mysqlicannot open shared object file:
     
    No such file or directory), /var/jenkins_home/workspace/PHP-7.2-Linux-x86_64/bi
    n
    /php7/lib/php/extensions/no-debug-zts-20170718/mysqli.so (/var/jenkins_home/wor
    kspace
    /PHP-7.2-Linux-x86_64/bin/php7/lib/php/extensions/no-debug-zts-20170718/my
    sqli
    .socannot open shared object fileNo such file or directory)) in Unknown
    on line 0

    Warning
    PHP StartupUnable to load dynamic library 'mysqli' (tried: /var/jenki
    ns_home
    /workspace/PHP-7.2-Linux-x86_64/bin/php7/lib/php/extensions/no-debug-zts-
    20170718/mysqli (/var/jenkins_home/workspace/PHP-7.2-Linux-x86_64/bin/php7/lib/p
    hp
    /extensions/no-debug-zts-20170718/mysqlicannot open shared object fileNo s
    uch file 
    or directory), /var/jenkins_home/workspace/PHP-7.2-Linux-x86_64/bin/php
    7
    /lib/php/extensions/no-debug-zts-20170718/mysqli.so (/var/jenkins_home/workspac
    e
    /PHP-7.2-Linux-x86_64/bin/php7/lib/php/extensions/no-debug-zts-20170718/mysqli.
    socannot open shared object fileNo such file or directory)) in Unknown on li
    ne 0
     
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Your mysql connector was idle for too long. Catch the exception and ping your mysql connector https://www.php.net/manual/en/mysqli.ping.php
    Or just implement a keep-alive tactic like the SFTP clients do (keep pinging mysql connector every 5 minutes or so).
     
    Last edited: Aug 14, 2019
    OnTheVerge likes this.
  4. Barry_Bradley

    Barry_Bradley Spider

    Messages:
    13
    ErrorException: "mysqli: ping(): MySQL serv
    er has gone away"
     
  5. ShushImSam

    ShushImSam Spider Jockey

    Messages:
    37
    "The MySQL server has gone away (error 2006) has two main causes and solutions:Server timed out and closed the connection.
    To Fix:

    "
    - To fix, check that wait_timeout mysql variable in your my.cnf configuration file is large enough.

    - You may also need to increase the innodb_log_file_size mysql variable in your my.cnf configuration to for example 128MB or higher.
    "
     
  6. Barry_Bradley

    Barry_Bradley Spider

    Messages:
    13
    What the problem?
     
  7. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    This error occurs if no queries or pings happen between server and database. The simplest way to fix without changing MySQL settings would be to ping the database every minute.
     
  8. Barry_Bradley

    Barry_Bradley Spider

    Messages:
    13
    [QUOTE = "SOFe, post: 65999, member: 4"] Эта ошибка возникает, если между сервером и базой данных не происходит никаких запросов или эхо-запросов. Самый простой способ исправить это без изменения настроек MySQL - это пинговать базу данных каждую минуту. [/ QUOTE]
    It is the problem bin file.
     
  9. Barry_Bradley

    Barry_Bradley Spider

    Messages:
    13
     
  10. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    No it isn't. It is MySQL setup problem. But regular pings can fix it without additional trouble.
     
    Destroyer57 likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.