Author Topic: Cannot connect to MySQL, db_conn.php is missing  (Read 387 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
Cannot connect to MySQL, db_conn.php is missing
« on: April 16, 2018, 01:10:29 AM »
Clean installation of CentOS 7 and CWP Control Web Panel. No errors anywhere.

Upon final reboot, I am able to access the login page for the control panel, but upon attempting to log in, I get the following error page:

Code: [Select]
Warning: main(../../resources/admin/include/db_conn.php): failed to open stream: No such file or directory in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Warning: main(../../resources/admin/include/db_conn.php): failed to open stream: No such file or directory in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Warning: main(): Failed opening '../../resources/admin/include/db_conn.php' for inclusion (include_path='.:/usr/local/cwp/php71/lib/php') in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Warning: main(/usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php): failed to open stream: No such file or directory in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

Warning: main(): Failed opening '/usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php' for inclusion (include_path='.:/usr/local/cwp/php71/lib/php') in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

Notice: Undefined variable: db_host in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

Notice: Undefined variable: db_user in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

Notice: Undefined variable: db_pass in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

Notice: Undefined variable: db_name in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0

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

Notice: Undefined variable: db_host in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Notice: Undefined variable: db_user in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Notice: Undefined variable: db_pass in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Notice: Undefined variable: db_name in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0

Warning: mysqli_connect(): (HY000/1045): Access denied for user ''@'localhost' (using password: NO) in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0
**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:

Please note:

  • I have confirmed that MySQL is installed and running properly by logging into MySQL using the root password provided during the installation summary.
  • I have re-set the MySQL root password via /scripts/mysql_pwd_reset, and again confirmed that it was up and running by logging in using the new root password provided by the script.
  • I have confirmed that /root/.my.cnf exists and has the proper MySQL root username and password.
  • I have gone to /usr/local/cwpsrv/htdocs/resources/admin/include/ and have confirmed that db_conn.php does NOT exist in that directory.

Essentially, I need to know where I can find a db_conn.php file to shoehorn into the correct directory.

Offline
*
Re: Cannot connect to MySQL, db_conn.php is missing
« Reply #1 on: April 16, 2018, 09:14:35 AM »
your installation wasn't good in some way if you are missing that files, here is part from the installer

Code: [Select]
cd /usr/local/cwpsrv/htdocs/resources/admin/include
wget http://dl1.centos-webpanel.com/files/cwp/sql/db_conn.txt
mv db_conn.txt db_conn.php

now edit this file and set details from /root/.my.cnf
Code: [Select]
nano /usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Offline
*
Re: Cannot connect to MySQL, db_conn.php is missing
« Reply #2 on: April 16, 2018, 03:50:49 PM »
The list of errors has shortened dramatically:

Code: [Select]
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'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 'root'@'localhost' (using password: YES) 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:

But I am still having problems.

I noticed that in the db_conn.php file, there was an entry for an encryption password. Does this need to be filled in order to clear up more errors?

EDIT: One sec, the password I was successful in logging onto MySQL with last night is no longer being accepted as the MySQL root password. I did *NOT* change it in the meantime.

EDIT 2: Okay, this is VERY, VERY WEIRD: even when I change the password through the change MySQL password script, I am unable to log onto MySQL using the new password. I was able to conduct a change password last night and was able to log into MySQL directly using the new password, but this morning it does not work.

EDIT3: And I Have confirmed that the change password script does change /root/.my.cnf and db_conn.php.

EDIT4: Okay, it is now Whisky Tango Foxtrot time. Remember how I said that one of my first actions were to re-set the MySQL root password? Yes, I did. I really, really did. And I even checked that new password afterwards, by logging straight into MySQL, and it was successful.

I have now discovered that the MySQL change root password script does NOTHING. Yes, it updates /root/.my.cnf and db_conn.php file with the “new” password it creates, but I have just discovered that any new password it creates is not actually used within MySQL. As in, I use the script, but MySQL does not recognize the new password.

In fact, it recognizes only the original password used on system install. It doesn’t even recognize the second password that was set up with my initial script run any more.

So my system now appears to be up and running, error free, using the original system install MySQL password even though the change password script was run, twice.

Confused? Join the club.
« Last Edit: April 16, 2018, 04:27:23 PM by rekabis »

Offline
*
Re: Cannot connect to MySQL, db_conn.php is missing
« Reply #3 on: April 17, 2018, 07:42:29 AM »
set something random for "crypt_pwd" with length as password, you can change your mysql password manually and then update this files

/usr/local/cwpsrv/htdocs/resources/admin/include/db_conn.php
/root/.my.cnf
VPS & Dedicated server provider with included FREE Managed support for CWP.
http://www.studio4host.com/

*** Don't allow that your server or website is down, choose hosting provider with included expert managed support for your CWP.

Offline
*
Re: Cannot connect to MySQL, db_conn.php is missing
« Reply #4 on: May 06, 2018, 08:31:57 PM »
You have to check error log which is in place /usr/local/cwpsrv/logs/error.log

option 1
if you dont have file ~/.my.cnf

2018/05/06 15:52:42 [error] 15352#0: *3609 FastCGI sent in stderr: "PHP message: PHP Warning:  mysqli_connect(): (HY000/2002): No such file or directory in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0
PHP message: PHP Warning:  mysqli_connect(): (HY000/2002): No such file or directory in /usr/local/cwpsrv/htdocs/resources/admin/include/functions.php on line 0
PHP message: PHP Warning:  mysqli_connect(): (HY000/2002): No such file or directory in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0
PHP message: PHP Warning:  mysqli_connect(): (HY000/2002): No such file or directory in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0
PHP message: PHP Warning:  mysqli_error() expects exactly 1 parameter, 0 given in /usr/local/cwpsrv/htdocs/admin/admin/index.php on line 0" while reading response header from upstream, client: XX.XX.XX.XX, server: localhost, request: "GET /admin/index.php?module=crontab HTTP/1.1", upstream: "fastcgi://unix:/usr/local/cwp/php71/var/sockets/cwpsrv.sock:", host: "www.dnsbg.com:2030", referrer: "http://www.domain.com:2030/admin/index.php?module=crontab"

Option 2:

If you have file ~/.my.cnf but information like password is wrong - error will be

2018/05/06 22:53:37 [error] 8815#0: *324 FastCGI sent in stderr: "PHP message: PHP Notice:  Undefined variable: pass in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 21
PHP message: PHP Warning:  mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 25
PHP message: PHP Warning:  mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 27
PHP message: PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 29
PHP message: PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 95
PHP message: PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 95
PHP message: PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 95
PHP message: PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 95
PHP message: PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 95
PHP message: PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 95
PHP message: PHP Warning:  mysqli::query(): Couldn't fetch mysqli in /usr/local/cwpsrv/var/services/oauth/v2/server/server.php on line 95
PHP message: PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) in /usr/local/cwpsrv/var/services/oauth/v2/server/OAuth2/Storage/Pdo.php:67
Stack trace:
#0 /usr/local/cwpsrv/var/services/oauth/v2/server/OAuth2/Storage/Pdo.php(67): PDO->__construct('mysql:dbname=oa...', 'root', ''

What can be wrong in the file ~./.my.cnf

Wrong

~./.my.cnf

[client]
user = root
password = mypassword

~./.my.cnf

Correct ( without space passowrd=mypassword )
[client]
user=root
password=mypassword

Regards,
kkovachki