mysql_error() expects parameter 1 to be resource, boolean given

Created:

2016-11-16 13:11:37 UTC

Modified:

2017-07-12 10:52:27 UTC

0

Was this article helpful?


Have more questions?

Submit a request

mysql_error() expects parameter 1 to be resource, boolean given

Symptoms

When enabling nginx using /usr/local/psa/admin/bin/nginxmng -e command, it fails with the following error:

PleskUtilException: /usr/local/psa/admin/bin/nginxmng '--enable' failed with message: PHP Warning: mysql_query() expects parameter 2 to be resource, boolean given; File: /usr/local/psa/admin/plib/db.php, Line: 97
PHP Warning: mysql_error() expects parameter 1 to be resource, boolean given; File: /usr/local/psa/admin/plib/db.php, Line: 101
PHP Warning: mysql_error() expects parameter 1 to be resource, boolean given; File: /usr/local/psa/admin/plib/db.php, Line: 104

Or a website shows an error:

502 Bad Gateway nginx 

 The following warnings in Subscriptions > example.com > Websites & Domains > Logs:

mod_fcgid: stderr: PHP Warning: mysql_error() expects parameter 1 to be resource, boolean given in /var/www/vhosts/example.com/httpdocs/guruji/classdb.php on line 45 

Cause

MySQL connection timeout.

Resolution

  1. Check the following values in /etc/my.cnf :

    [root@server ~]# grep 'interactive_timeout' /etc/my.cnf
    interactive_timeout=100

    [root@server ~]# grep 'wait_timeout' /etc/my.cnf
    wait_timeout=15
  2. Open /etc/my.cnf in text editor on the server and consider to increase them.

    NOTE: According to MySQL documentation the default value for interactive_timeout and for wait_timeout is 28800

  3. Restart MySQL service:

    # service mysqld restart
  4. Enable nginx:

    # /usr/local/psa/admin/bin/nginxmng -e
Have more questions? Submit a request
Please sign in to leave a comment.