Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not connect to MySQL - Shared in Hosting (Locaweb) #4413

Closed
gvleite opened this issue Aug 5, 2018 · 17 comments · Fixed by #4444
Closed

Could not connect to MySQL - Shared in Hosting (Locaweb) #4413

gvleite opened this issue Aug 5, 2018 · 17 comments · Fixed by #4444

Comments

@gvleite
Copy link

gvleite commented Aug 5, 2018

I can not complete the process of a new installation because I get the error:

Could not connect to MySQL on 179.188.16.35 on port 3306 as fp_mychurchcrm. Please check the settings in Include / Config.php.
MySQL Error:

I can connect to the database server through my computer and through the server with no problems.

None of the other issues solved my problem.

If you have the ChurchCRM software running, please file an issue using the Report an issue in the help menu.

On what page in the application did you find this issue?

Setup

On what type of server is this running? Dedicated / Shared hosting? Linux / Windows?

Shared in Hosting (Locaweb) Linux

What browser (and version) are you running?

Google Chrome 67.0.3396.99

What version of PHP is the server running?

7

What version of SQL Server are you running?

5.6

What version of ChurchCRM are you running?

3.0.7

@crossan007 crossan007 added this to the User Support milestone Aug 6, 2018
@crossan007
Copy link
Contributor

Please check the values in your Config.php on your server.

@gvleite
Copy link
Author

gvleite commented Aug 7, 2018

The information contained in Config.php is correct, I tested the connection both by the server and the client of my computer.

The following is the model:

// Database connection constants
$ sSERVERNAME = '179.188.16.35';
$ dbPort = '3306';
$ sUSER = 'fp_mychurchcrm';
$ sPASSWORD = 'xxx';
$ sDATABASE = 'fp_mychurchcrm';

// Root path of your ChurchCRM installation (THIS MUST BE SET CORRECTLY!)
//
// Examples:
// - if you will be accessing from http://www.yourdomain.com/churchcrm then you would enter '/ churchcrm' here.
// - if you will be accessing from http://www.yourdomain.com then you would enter '' ... an empty string for a top level installation.
//
// NOTE:
// - the path SHOULD Start with slash, if not ''.
// - the path SHOULD NOT end with slash.
// - the is case sensitive.
$ sRootPath = '';

// Set $ ​​bLockURL = TRUE to enforce https access by specifying exactly
// which URL's your users may use to log into ChurchCRM.
$ bLockURL = FALSE;

// URL [0] is the URL that you prefer most users use when they
// Login. These are case sensitive.
$ URL [0] = 'http://members.familiaplena.net/';
// List as many other URL's as may be needed. Number them sequentially.
// $ URL [1] = 'https://www.mychurch.org/churchcrm/';

@crossan007
Copy link
Contributor

@MrClever any ideas here? Really seems like a username / password issue.

@gvleite
Copy link
Author

gvleite commented Aug 21, 2018

I opened a call on my hosting provider (Locaweb), and received the following response:

The application is trying to use root access on the server, it is not possible on shared hosting.

Because super user changes would impact the other clients that are on the same server. The application also uses Python, and the module is not used in shared hosting.

Does ChurchCRM really need root access?
And he uses Pyton, I do not remember meeting the prerequisites.

There is something you can help me with, I would love to implement the application in my church.

@crossan007
Copy link
Contributor

That sounds wrong.

A production installation of ChurchCRM does not use root, nor does it use Python.

Are you sure you downloaded the correct zip file from the release page?
ChurchCRM-3.0.7.zip 16.2 MB

@gvleite
Copy link
Author

gvleite commented Aug 21, 2018

Yes, I tested both ChurchCRM-3.0.7 and ChurchCRM-3.0.6.

the error log is this:

Mon Aug 20 09:59:35 2018] [error] [client 186.202.102.84] PHP Fatal error: Call to undefined function ChurchCRM \ dto \ random_bytes () in / home / storage / 9 / c7 / public_html / members / ChurchCRM / dto / SystemURLs.php on line 28
[Mon Aug 20 09:59:36 2018] [error] [client 189.84.177.91] ModSecurity: Access denied with code 403 (phase 1). String match "python-requests /" at REQUEST_HEADERS: User-Agent. [file "/etc/modsecurity/locaweb-rules/activated_rules/Locaweb_98_wordpress.conf"] [line "43"] [id "99034"] [msg "Locaweb Custom Rules: python-requests wordpress login attempt"] [hostname "www .familiaplena.net "] [uri" /wp-login.php "] [unique_id" W3q7OLrKmasAANvHFWgAAAAU "]
[Mon Aug 20 09:59:36 2018] [error] [client 189.84.177.91] (2) No such file or directory: /home/httpd/error/noindex.html.var

Is there anything I can do?

Thankful,

@crossan007
Copy link
Contributor

Oh.

This error comes from using the wrong version of PHP. You need at least 7.0

@gvleite
Copy link
Author

gvleite commented Aug 22, 2018

I did one more test to see the PHP version.

The result is attached.
php

@peseotni
Copy link

peseotni commented Aug 27, 2018

I have the same issue.
with versions prior to churchcrm 3, everything works well with the settings. this problem started with version 3.

@MrClever
Copy link
Collaborator

MrClever commented Aug 28, 2018

Late to the ticket - my apologies. A few things:

  1. Why is Config.php using a publicly routable IP address? Some configs have loopback routing (aka trombone/hair-pin routing) to transparently redirect to loopback for connections from the same host, other times it will just fail. Basically - don't rely on it; if your setup is co-hosting the database and web server on the same host, use loopback (ie, 127.0.0.1 - see next item). I tested the IP address in your config and your hosting provider is exposing MySQL to the world(!!):
$ telnet 179.188.16.35 3306
Trying 179.188.16.35...
Connected to robb0331.publiccloud.com.br.
Escape character is '^]'.
S
5.6.35-81.0-logmBkc:7C+N(��IAJ2WC*E]#6'mysql_native_password

I can't emphasise enough just how utterly bad this is! It's not even encrypted!! :(

  1. Try using 127.0.0.1 as the $sSERVERNAME target and test again.
  2. If option 2 fails (above), change to localhost which is handled differently in the mysqli connection library (forces use of a UNIX socket pipe as opposed to a TCP/IP connection).

EDIT: the screenshot above seems to suggest the ChurchCRM system is installed in /membros (or maybe /members?) on the web server. If so, please make sure you set $sRootPath='/membros'; in Config.php.

@MrClever
Copy link
Collaborator

MrClever commented Aug 28, 2018

Update... I've found a bug in the implementation of #4071 (my code...I'm an idiot :P). Basically the carry-over from the old mysql_connect days where you could use host:port, eg 127.0.0.1:3306 as the connection target won't work in the new shiny mysqli_connect. I've tested the fix and will have a PR ready in a few minutes. This will affect anyone not using UNIX Sockets or Windows named pipes for DB connections.

@MrClever
Copy link
Collaborator

PR #4444 created to fix this issue. @crossan007 / @DawoudIO please review and consider pushing out a patch release - this is a bit of a problem and I feel bad because it was my code that caused it :( Apologies to all affected!

@gvleite gvleite closed this as completed Aug 28, 2018
@ghost ghost removed the In Review label Aug 28, 2018
@gvleite
Copy link
Author

gvleite commented Aug 28, 2018

I tried to follow the steps, but I did not succeed.
Remember that I use a hosting service and the web and database servers are different.

As for correcting the problem found in the code, should I wait for the release of a new version to validate?

Thank you.

@gvleite gvleite reopened this Aug 28, 2018
@MrClever
Copy link
Collaborator

@gvleite - if your hosting provider has separated the web and database servers then using localhost/127.0.0.1 won't work, so there's that. I'd still follow up with them on the unencrypted, world-exposed MySQL database though. Secondly, the fix is pretty simple - it's actually a single line in the LoadConfigs.php file. My fixed version is here - here are the changes from the current version.

Essentially, you need to modify line 81 in the 3.0.7/3.0.8 Include/LoadConfigs.php file from this:

$cnInfoCentral = mysqli_connect($sSERVERNAME.':'.$dbPort, $sUSER, $sPASSWORD)

to this

$cnInfoCentral = mysqli_connect($sSERVERNAME, $sUSER, $sPASSWORD, null, $dbPort)

If you can't edit the file on the host upload a new copy with the changes made locally on your PC etc.

Be aware, the file integrity check will break when you modify a file directly like I've suggested, but it should get you started with a connection to the database. When this fix is rolled into a release, the update process will install the new version.

@gvleite
Copy link
Author

gvleite commented Aug 29, 2018

I was able to do the editing,
But CRM does not load anymore, it returns HTTP ERROR 500.
Is there anything else I can do?

@MrClever
Copy link
Collaborator

We see this a lot: https://github.com/ChurchCRM/CRM/wiki/500-Error

@gvleite
Copy link
Author

gvleite commented Aug 29, 2018

I changed the permissions, as guidance did not solve.

But when I return Include/LoadConfigs.php to the original value it reopens the CRM, but with the connection error of the database.

I'll stick to the new version with the fix.

Thanks for the help so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants