Author Topic: Mysqli connection refused for root user in Cent OS  (Read 6839 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Mysqli connection refused for root user in Cent OS
« on: June 14, 2021, 08:35:04 PM »
Suddenly I got this error while trying to login to the CWP Control panel.

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 have tried resetting the root password too. Also I have checked and confirm that the root password is same in both /usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php and /root/.my.cnf

Someone please help.

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #1 on: June 15, 2021, 02:03:20 PM »
Paste the last contents of this log file
Code: [Select]
/var/lib/mysql/your-HOSTNAME.err
To do this use SSH. open the file using
Code: [Select]
vi /var/lib/mysql/your-HOSTNAME.err
Also do the same for this log -
Code: [Select]
/var/log/cwp_client_login.log
« Last Edit: June 15, 2021, 02:06:20 PM by josephgodwinke »
Applications Developer | RHEL Linux Server Administrator

Reach out to me in pm to solve any application deployment such as NodeJS, Java, PHP etc


Managed 40gb Shared CWP PRO Hosting for $20 p/a offer
Managed 60gb Shared CWP PRO Hosting for $40 p/a offer
Managed 100gb Shared CWP PRO Hosting for $60 p/a offer
Managed 200gb Shared CWP PRO Hosting for $120 p/a offer


CentOS 8 died a premature death at the end of 2021 - migrate to RockyLinux Os.

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #2 on: June 16, 2021, 09:48:55 AM »
such files not available in the mentioned directories.

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #3 on: June 16, 2021, 06:21:49 PM »
replace your-HOSTNAME with your actual hostname
Applications Developer | RHEL Linux Server Administrator

Reach out to me in pm to solve any application deployment such as NodeJS, Java, PHP etc


Managed 40gb Shared CWP PRO Hosting for $20 p/a offer
Managed 60gb Shared CWP PRO Hosting for $40 p/a offer
Managed 100gb Shared CWP PRO Hosting for $60 p/a offer
Managed 200gb Shared CWP PRO Hosting for $120 p/a offer


CentOS 8 died a premature death at the end of 2021 - migrate to RockyLinux Os.

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #4 on: June 16, 2021, 06:25:18 PM »
I got you, but the files doesn't exist. I only have the last file i.e. cwp_client_login.log

Code: [Select]
2021-06-16 21:08:38 root Successful Login from: 59.94.72.224 on: https://localhost:2031/login/index.php
2021-06-16 21:15:17 root Successful Login from: 59.94.72.224 on: https://localhost:2031/login/index.php
2021-06-16 21:19:07 root Successful Login from: 59.94.72.224 on: https://localhost:2087/login/index.php

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #5 on: June 16, 2021, 07:03:06 PM »
Try update CWP from ssh

Code: [Select]
sh /usr/local/cwpsrv/htdocs/resources/scripts/update_cwp
Applications Developer | RHEL Linux Server Administrator

Reach out to me in pm to solve any application deployment such as NodeJS, Java, PHP etc


Managed 40gb Shared CWP PRO Hosting for $20 p/a offer
Managed 60gb Shared CWP PRO Hosting for $40 p/a offer
Managed 100gb Shared CWP PRO Hosting for $60 p/a offer
Managed 200gb Shared CWP PRO Hosting for $120 p/a offer


CentOS 8 died a premature death at the end of 2021 - migrate to RockyLinux Os.

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #6 on: June 16, 2021, 07:59:58 PM »
Getting the same error while updating cwp too:

Code: [Select]
[root@vmi426849 ~]# sh /usr/local/cwpsrv/htdocs/resources/scripts/update_cwp


====================================================
============= CentOS Web Panel Cron ================
====================================================


###########################
Firewall Flush Daily Blocks
###########################


######################
Update Server Packages
######################
PHP Warning:  mysqli_connect(): (HY000/2002): Connection refused in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0
PHP Warning:  mysqli_connect(): (HY000/2002): Connection refused in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0
PHP Warning:  mysqli_connect(): (HY000/2002): Connection refused in /usr/local/cwpsrv/htdocs/resources/admin/include/cron.php on line 0
PHP Warning:  mysqli_select_db() expects parameter 1 to be mysqli, boolean given in /usr/local/cwpsrv/htdocs/resources/admin/include/cron.php on line 0
[root@vmi426849 ~]#
« Last Edit: June 16, 2021, 08:02:09 PM by amlanrd »

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #7 on: June 17, 2021, 12:28:32 AM »
Reset MySQL password by first stopping all processes using mysql
Code: [Select]
killall mysqld then start mysql removing all permissions
Code: [Select]
mysqld_safe --skip-grant-tables
Now reset the password with sql query
Code: [Select]
update user set Password=PASSWORD('your-new-password') where user='root';
Flush privileges and restart mysql service
Code: [Select]
service restart mysql
Applications Developer | RHEL Linux Server Administrator

Reach out to me in pm to solve any application deployment such as NodeJS, Java, PHP etc


Managed 40gb Shared CWP PRO Hosting for $20 p/a offer
Managed 60gb Shared CWP PRO Hosting for $40 p/a offer
Managed 100gb Shared CWP PRO Hosting for $60 p/a offer
Managed 200gb Shared CWP PRO Hosting for $120 p/a offer


CentOS 8 died a premature death at the end of 2021 - migrate to RockyLinux Os.

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #8 on: June 17, 2021, 08:57:47 AM »
Syntax error after 3rd step:

Code: [Select]
[root@vmi426849 ~]# killall mysqld
[root@vmi426849 ~]# mysqld_safe --skip-grant-tables
210617 14:25:06 mysqld_safe Logging to '/var/lib/mysql/vmi426849.cubinix.com.err'.
210617 14:25:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@vmi426849 ~]# update user set Password=PASSWORD('5d89TF5Ug3N06qg') where user='root';
-bash: syntax error near unexpected token `('
[root@vmi426849 ~]#

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #9 on: June 17, 2021, 09:34:11 AM »
The last command is a mysql command open mysql from ssh using command
Code: [Select]
mysql --user=root mysql
Applications Developer | RHEL Linux Server Administrator

Reach out to me in pm to solve any application deployment such as NodeJS, Java, PHP etc


Managed 40gb Shared CWP PRO Hosting for $20 p/a offer
Managed 60gb Shared CWP PRO Hosting for $40 p/a offer
Managed 100gb Shared CWP PRO Hosting for $60 p/a offer
Managed 200gb Shared CWP PRO Hosting for $120 p/a offer


CentOS 8 died a premature death at the end of 2021 - migrate to RockyLinux Os.

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #10 on: June 17, 2021, 04:02:05 PM »
Hi,

I tried something else and it fixed almost 90% of the issue.

1. I have taken backup of the database folders from /var/lib/mysql/
2. Removed MariaDB and the directories.
3. Reinstalled the MariaDB.
4. Copied the backed up database folders to /var/lib/mysql/
5. Granted permissions to the folder.
6. Reset myswl password.

Now I can login to my CWP. But still I'm getting the following error message in the header area:
Code: [Select]
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'postfix'@'localhost' (using password: YES) in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'postfix'@'localhost' (using password: YES) in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Also, the FTP Server showing failed in the CWP Dashboard. If I try to start, it shows:
Code: [Select]
Failed to start pure-ftpd.service: Unit pure-ftpd.service not found.

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #11 on: June 17, 2021, 05:22:25 PM »
I have fixed the postfix issue. And for FTP issue, I have reinstalled pure-ftpd. The FTP service is now started. But in the FTP status I noticed this line:
Code: [Select]
Jun 17 22:48:10 vmi426849.cubinix.com systemd[1]: pure-ftpd.service: Can't open PID file /var/run/pure-ftpd.pid (yet?) after start: No such file or directoryPlease help!

Offline
*
Re: Mysqli connection refused for root user in Cent OS
« Reply #12 on: June 18, 2021, 01:32:00 PM »
Code: [Select]
chown root:pure-ftpd /var/run/pure-ftpd.pid
chmod 755 /var/run/pure-ftpd
Applications Developer | RHEL Linux Server Administrator

Reach out to me in pm to solve any application deployment such as NodeJS, Java, PHP etc


Managed 40gb Shared CWP PRO Hosting for $20 p/a offer
Managed 60gb Shared CWP PRO Hosting for $40 p/a offer
Managed 100gb Shared CWP PRO Hosting for $60 p/a offer
Managed 200gb Shared CWP PRO Hosting for $120 p/a offer


CentOS 8 died a premature death at the end of 2021 - migrate to RockyLinux Os.