Author Topic: MySQL Connection refused  (Read 14743 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
MySQL Connection refused
« on: January 06, 2019, 09:15:33 PM »
I had a problem with power failure on my vps, and when the energy comes back, I no longer have access to mysql.
Introducing the following error in the CWP login page.
Code: [Select]
Warning: mysqli_connect(): (HY000/2002): Connection refused in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

Warning: mysqli_connect(): (HY000/2002): Connection refused in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

Warning: mysqli_connect(): (HY000/2002): Connection refused in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Warning: mysqli_connect(): (HY000/2002): Connection refused in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0


Trying to start mysql server, please wait!
Try to restart CentOS Web Panel with command: sh /scripts/restart_cwpsrv

**Check your MySQL root password in: /usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php and /root/.my.cnf


Warning: mysqli_error() expects exactly 1 parameter, 0 given in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0
Could not connect:

I tried to find some solution by google and looking at some topics here in the forum.
But I did not succeed, Then I removed mysql and mariadb from the server and reinstalled.

But when I go to configure the same error appears.
Code: [Select]
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111 "Connection refused")


If someone can give me a light, I would be grateful.

Offline
***
Re: MySQL Connection refused
« Reply #1 on: January 06, 2019, 09:23:03 PM »
Check if the passwords match between files:
/usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php
and
/root/.my.cnf

If the passwords mismatch, correct them.
It must be exact same in both files.

Restart mysql:
# systemctl restart mariadb (if in CentOS7)
or
# service mariadb restart (if in CentOS6)

Regards,
Netino

Offline
*
Re: MySQL Connection refused
« Reply #2 on: January 06, 2019, 09:31:21 PM »
Yes, I've tried that.
was one of my first attempts to solve it.  :'(
In my last attempt I removed mysql and mariadb, but after I reinstalled, it remained the same.

Now when I try to connect mysql or mariadb it appears like this.
"Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details."

Offline
***
Re: MySQL Connection refused
« Reply #3 on: January 06, 2019, 11:36:40 PM »
What shows the commands "systemctl status mariadb.service" or "journalctl -xe"..??

Offline
*
Re: MySQL Connection refused
« Reply #4 on: January 06, 2019, 11:46:04 PM »
systemctl status mariadb.service
Return.
Code: [Select]
● mariadb.service - MariaDB 10.1.37 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: failed (Result: exit-code) since Dom 2019-01-06 21:41:11 -02; 2s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 57091 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
  Process: 57079 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 57078 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 57091 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

Jan 06 21:41:07 japora.net mysqld[57091]: InnoDB: Set innodb_force_recovery to ignore this error.
Jan 06 21:41:07 japora.net mysqld[57091]: 2019-01-06 21:41:07 140472844998912 [ERROR] Plugin 'InnoDB' init function returned error.
Jan 06 21:41:07 japora.net mysqld[57091]: 2019-01-06 21:41:07 140472844998912 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Jan 06 21:41:07 japora.net mysqld[57091]: 2019-01-06 21:41:07 140472844998912 [Note] Plugin 'FEEDBACK' is disabled.
Jan 06 21:41:07 japora.net mysqld[57091]: 2019-01-06 21:41:07 140472844998912 [ERROR] Unknown/unsupported storage engine: InnoDB
Jan 06 21:41:07 japora.net mysqld[57091]: 2019-01-06 21:41:07 140472844998912 [ERROR] Aborting
Jan 06 21:41:11 japora.net systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jan 06 21:41:11 japora.net systemd[1]: Failed to start MariaDB 10.1.37 database server.
Jan 06 21:41:11 japora.net systemd[1]: Unit mariadb.service entered failed state.
Jan 06 21:41:11 japora.net systemd[1]: mariadb.service failed.



journalctl -xe
Return.
Code: [Select]
Jan 06 21:42:27 japora.net mysqld[57367]: 2019-01-06 21:42:27 140120371190016 [ERROR] Unknown/unsupported storage engine: InnoDB
Jan 06 21:42:27 japora.net mysqld[57367]: 2019-01-06 21:42:27 140120371190016 [ERROR] Aborting
Jan 06 21:42:27 japora.net systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jan 06 21:42:27 japora.net systemd[1]: Failed to start MariaDB 10.1.37 database server.
-- Subject: A unidade mariadb.service falhou
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The mariadb.service failed.
--
-- The result is failed.
Jan 06 21:42:27 japora.net systemd[1]: Unit mariadb.service entered failed state.
Jan 06 21:42:27 japora.net systemd[1]: mariadb.service failed.
Jan 06 21:42:27 japora.net rsyslogd[930]: imjournal: rename() failed for new path: '/var/lib/rsyslog/imjournal.state': Is a directory [v8.24.0 try http://www.rsyslog.com/e/0 ]
Jan 06 21:42:28 japora.net polkitd[613]: Registered Authentication Agent for unix-process:57382:1812058 (system bus name :1.149 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/Po
Jan 06 21:42:28 japora.net systemd[1]: Starting MariaDB 10.1.37 database server...
-- Subject: Unidade mariadb.service sendo iniciado
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The mariadb.service drive is starting.
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] /usr/sbin/mysqld (mysqld 10.1.37-MariaDB) starting as process 57401 ...
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: innodb_empty_free_list_algorithm has been changed to legacy because of small buffer pool size. In order to use bac
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: Using mutexes to ref count buffer pool pages
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: The InnoDB memory heap is disabled
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: Compressed tables use zlib 1.2.7
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: Using Linux native AIO
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: Using SSE crc32 instructions
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: Initializing buffer pool, size = 128.0M
Jan 06 21:42:28 japora.net rsyslogd[930]: imjournal: rename() failed for new path: '/var/lib/rsyslog/imjournal.state': Is a directory [v8.24.0 try http://www.rsyslog.com/e/0 ]
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: Completed initialization of buffer pool
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] InnoDB: Highest supported file format is Barracuda.
Jan 06 21:42:28 japora.net mysqld[57401]: InnoDB: Set innodb_force_recovery to ignore this error.
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [ERROR] Plugin 'InnoDB' init function returned error.
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [Note] Plugin 'FEEDBACK' is disabled.
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [ERROR] Unknown/unsupported storage engine: InnoDB
Jan 06 21:42:28 japora.net mysqld[57401]: 2019-01-06 21:42:28 140251230583040 [ERROR] Aborting
Jan 06 21:42:28 japora.net rsyslogd[930]: imjournal: rename() failed for new path: '/var/lib/rsyslog/imjournal.state': Is a directory [v8.24.0 try http://www.rsyslog.com/e/0 ]
Jan 06 21:42:28 japora.net systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jan 06 21:42:28 japora.net systemd[1]: Failed to start MariaDB 10.1.37 database server.
-- Subject: A unidade mariadb.service falhou
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The mariadb.service failed.
--
-- The result is failed.
Jan 06 21:42:28 japora.net systemd[1]: Unit mariadb.service entered failed state.
Jan 06 21:42:28 japora.net systemd[1]: mariadb.service failed.
Jan 06 21:42:28 japora.net rsyslogd[930]: imjournal: rename() failed for new path: '/var/lib/rsyslog/imjournal.state': Is a directory [v8.24.0 try http://www.rsyslog.com/e/0 ]
Jan 06 21:42:28 japora.net polkitd[613]: Unregistered Authentication Agent for unix-process:57382:1812058 (system bus name :1.149, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale pt_BR.UT

Offline
***
Re: MySQL Connection refused
« Reply #5 on: January 07, 2019, 12:50:14 AM »
Your system is claiming about InnoDB:
Code: [Select]
Unknown/unsupported storage engine: InnoDB

But it is claiming too about rsyslogd/imjounal:
Code: [Select]
imjournal: rename() failed for new path: '/var/lib/rsyslog/imjournal.state': Is a directory [v8.24.0 try http://www.rsyslog.com/e/0 ]

Post the result of the command:
Code: [Select]
ls -alF /var/lib/rsyslog/imjournal.state

As you mention had your server rebooted, may be journal files are in inconsistent state, and may be needed to repair it.
The things can do more complex a little bit, but you best choice at this moment would be to rename '/var/lib/rsyslog/imjournal.state' to '/var/lib/rsyslog/imjournal.state.old', and restart rsyslogd.

Are you using InnoDB..??
How much memory you have in your system..??
And swap..??
« Last Edit: January 07, 2019, 12:54:28 AM by Netino »

Offline
*
Re: MySQL Connection refused
« Reply #6 on: January 07, 2019, 01:07:01 AM »
ls -alF /var/lib/rsyslog/imjournal.state
Code: [Select]
total 0
drwx------  3 root root 17 Jan  6 16:40 ./
drwx------. 2 root root 56 Jan  6 23:02 ../
drwxrwxrwt  2 root root  6 Jan  6 16:40 tmp/

I already renamed and restarted.
return.
Code: [Select]
-rw------- 1 root root 123 Jan  6 23:03 /var/lib/rsyslog/imjournal.state
VPS 15GB Space/1GB RAM
What I have in this vps, a simple page, and we use it, just the roundcube.

Offline
***
Re: MySQL Connection refused
« Reply #7 on: January 07, 2019, 02:10:23 AM »
Try to restart mariadb and post the result of commands "systemctl status mariadb.service" and "journalctl -xe".

Offline
*
Re: MySQL Connection refused
« Reply #8 on: January 07, 2019, 02:25:04 PM »
systemctl restart mariadb.service

Code: [Select]
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
[root@japora home]# systemctl status mariadb.service
● mariadb.service - MariaDB 10.1.37 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: failed (Result: exit-code) since Seg 2019-01-07 12:14:51 -02; 4s ago
     Docs: man:mysqld(8)
           https://mariadb.com/kb/en/library/systemd/
  Process: 900 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
  Process: 888 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 886 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
 Main PID: 900 (code=exited, status=1/FAILURE)
   Status: "MariaDB server is down"

Jan 07 12:14:51 japora.net mysqld[900]: InnoDB: Set innodb_force_recovery to ignore this error.
Jan 07 12:14:51 japora.net mysqld[900]: 2019-01-07 12:14:51 139853359798528 [ERROR] Plugin 'InnoDB' init function re...error.
Jan 07 12:14:51 japora.net mysqld[900]: 2019-01-07 12:14:51 139853359798528 [ERROR] Plugin 'InnoDB' registration as ...ailed.
Jan 07 12:14:51 japora.net mysqld[900]: 2019-01-07 12:14:51 139853359798528 [Note] Plugin 'FEEDBACK' is disabled.
Jan 07 12:14:51 japora.net mysqld[900]: 2019-01-07 12:14:51 139853359798528 [ERROR] Unknown/unsupported storage engi...InnoDB
Jan 07 12:14:51 japora.net mysqld[900]: 2019-01-07 12:14:51 139853359798528 [ERROR] Aborting
Jan 07 12:14:51 japora.net systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jan 07 12:14:51 japora.net systemd[1]: Failed to start MariaDB 10.1.37 database server.
Jan 07 12:14:51 japora.net systemd[1]: Unit mariadb.service entered failed state.
Jan 07 12:14:51 japora.net systemd[1]: mariadb.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

journalctl -xe

Code: [Select]
Jan 07 12:15:55 japora.net mysqld[1225]: 2019-01-07 12:15:55 140049690962176 [Note] Plugin 'FEEDBACK' is disabled.
Jan 07 12:15:55 japora.net mysqld[1225]: 2019-01-07 12:15:55 140049690962176 [ERROR] Unknown/unsupported storage engine: Inno
Jan 07 12:15:55 japora.net mysqld[1225]: 2019-01-07 12:15:55 140049690962176 [ERROR] Aborting
Jan 07 12:15:55 japora.net systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jan 07 12:15:55 japora.net systemd[1]: Failed to start MariaDB 10.1.37 database server.
-- Subject: A unidade mariadb.service falhou
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The mariadb.service failed.
--
-- The result is failed.
Jan 07 12:15:55 japora.net systemd[1]: Unit mariadb.service entered failed state.
Jan 07 12:15:55 japora.net systemd[1]: mariadb.service failed.
Jan 07 12:16:03 japora.net kernel: Firewall: *UDP_IN Blocked* IN=ens33 OUT= MAC=ff:ff:ff:ff:ff:ff:64:d1:54:51:11:53:08:00 SRC
Jan 07 12:16:06 japora.net systemd[1]: Starting MariaDB 10.1.37 database server...
-- Subject: Unidade mariadb.service sendo iniciado
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The mariadb.service drive is starting.
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] /usr/sbin/mysqld (mysqld 10.1.37-MariaDB)
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: innodb_empty_free_list_algorithm
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: Using mutexes to ref count buffer
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: The InnoDB memory heap is disable
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: Mutexes and rw_locks use GCC atom
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: GCC builtin __atomic_thread_fence
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: Compressed tables use zlib 1.2.7
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: Using Linux native AIO
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: Using SSE crc32 instructions
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: Initializing buffer pool, size =
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: Completed initialization of buffe
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] InnoDB: Highest supported file format is
Jan 07 12:16:06 japora.net mysqld[1270]: InnoDB: Set innodb_force_recovery to ignore this error.
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [ERROR] Plugin 'InnoDB' init function returned e
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [ERROR] Plugin 'InnoDB' registration as a STORAG
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [Note] Plugin 'FEEDBACK' is disabled.
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [ERROR] Unknown/unsupported storage engine: Inno
Jan 07 12:16:06 japora.net mysqld[1270]: 2019-01-07 12:16:06 139882949712128 [ERROR] Aborting
Jan 07 12:16:06 japora.net systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jan 07 12:16:06 japora.net systemd[1]: Failed to start MariaDB 10.1.37 database server.
-- Subject: A unidade mariadb.service falhou
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The mariadb.service failed.
--
-- The result is failed.
Jan 07 12:16:06 japora.net systemd[1]: Unit mariadb.service entered failed state.
Jan 07 12:16:06 japora.net systemd[1]: mariadb.service failed.
Jan 07 12:16:08 japora.net kernel: Firewall: *UDP_IN Blocked* IN=ens33 OUT= MAC=ff:ff:ff:ff:ff:ff:6c:3b:6b:83:a1:3d:08:00 SRC
Jan 07 12:16:08 japora.net kernel: Firewall: *UDP_IN Blocked* IN=ens33 OUT= MAC=ff:ff:ff:ff:ff:ff:00:0c:42:75:93:c4:08:00 SRC
Jan 07 12:16:09 japora.net kernel: Firewall: *UDP_IN Blocked* IN=ens33 OUT= MAC=ff:ff:ff:ff:ff:ff:6c:3b:6b:bb:32:12:08:00 SRC

I'm almost believing that I have to format the machine.

Offline
***
Re: MySQL Connection refused
« Reply #9 on: January 10, 2019, 03:54:07 AM »
I think is not needed to format your system.

Try to repair your journal before, following a tutorial like this:
https://z900collector.wordpress.com/2016/11/10/repairing-centos-7-journal-corruption/

This is not difficult, just a little bit laborious.
Moreover, it is a necessary knowledge for any administrator to administer a server.

Regards,
Netino