Web hosting - Connecting to MySQL Server... ERROR

nikosarg wrote on Thursday, February 05, 2015:

Hello,

I am trying to configure OpenEMR on a shared web hosting service.
I have seen that this question has been asked before but I couldn’t find an answer to bypass this issue.

I am using cpanel and I followed these instructions for the configuration:
http://www.open-emr.org/wiki/index.php/Hosted_OpenEMR

I’m always getting this error:
"OpenEMR Setup
Step 3
Configuring OpenEMR…
Connecting to MySQL Server… ERROR. Check your login credentials. unable to connect to database as user: ‘username_openemr’ "

I asked for help from the web hosting service provider but they said that everything is ok from their side.

I also tried to check the connection to the database by myself using the following php file on the server:

<?php
    $servername = "localhost";
    $database = "username_openemr";
    $username = "username_openemr";
    $password = "xxxxxxxx";

    // Create connection
    $conn = new mysqli($servername, $username, $password);
    
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    echo "Connected successfully\n";
    
    $selected = mysqli_select_db($database,$conn)
      or die("Could not select database");
?>

The output I get is “Connected successfully Could not select database”. It seems that the credentials are working but the database cannot be selected.

Do you have any solution to this issue?
What could I ask the web hosting service provider if the problem comes from their side?

fsgl wrote on Friday, February 06, 2015:

In Step 2 carefully complete the MySQL Server section.

The Server Host is not localhost, but the IP address of the server running MySQL. Enter the Database Name, Login Name and Password from MySQL Creation above.

The User Hostname is not localhost, but the IP address of the server running Apache/PHP.

Incorrect entries will mean an installation failure.

nikosarg wrote on Saturday, February 07, 2015:

I used the IP address of the server running MySQL with no success. I still get the same error.

I tried the first option to have the set up create the database for me, instead of the option “I have already created the database”. The connection to MySQL was successful but creating the database fails. I get the following error:

Step 3

Configuring OpenEMR…

Connecting to MySQL Server… OK.
Creating database… ERROR. Check your login credentials. unable to execute SQL: ‘create >database username_openemr character set utf8 collate utf8_general_ci’ due to:

In this case I used the localhost as server host instead of the IP address of the server running MySQL.
If I use the IP address of the server running MySQL I see again this error:

OpenEMR Setup

Step 3

Configuring OpenEMR…

Connecting to MySQL Server… ERROR. Check your login credentials. unable to connect to database as root

Any help or advice would be most welcome!

cmswest wrote on Saturday, February 07, 2015:

Can you turn on the ssh server in cpanel? Then you could log in to your host and try to access your mysql openemr database from the command line .

blankev wrote on Saturday, February 07, 2015:

You have to login with the credentials you use to login in c-panel.

Do not use the credentials used for OpenEMR administator but the credentials needed to create the database.

Once installed login with OpenEMR administrator credentials an direct your browser to whatever path is needed to find OpenEMR. Be sure the folder has the name: openEMR. Afted extrating the folder is called OpenEMR-4.2.0

You can construct the Path with the information found in the file manager of c-panel

fsgl wrote on Saturday, February 07, 2015:

Hi Stephen, the command line is not available in cPanel or in any type of hosting.

I fail to see the attraction of hosting because of cost, which is zero with localhost & the lack of control, which is maximal on a local server.

Must be a craze.

fsgl wrote on Saturday, February 07, 2015:

In a hosted environment MySQL has been pre-installed & is already running; therefore the database must be created from cPanel, not with the OpenEMR setup.

The only way to have OpenEMR setup create the database is to stop MySQL first in the host. You do not have the capability to start/stop MySQL at will, hence OpenEMR setup cannot be used for database creation.

If you follow these Wiki article instructions exactly but continue to have difficulty connecting to the database created in cPanel, try using the web address instead of the IP address of the MySQL server.

blankev wrote on Saturday, February 07, 2015:

In Cpanel you can find particulars about your database with:

MySQL Databases of MySQL Database Wizard. This is also the way to go to create users and passwords for the Database.

visolveemr wrote on Saturday, February 07, 2015:

Nikos Argi,

Also make sure MySQL user has proper permission to create database.

Thanks
OpenEMR Customization/Support Team,
ViSolve Inc
services@visolve.com
Demo’s @ ViSolve Demo Library

cmswest wrote on Sunday, February 08, 2015:

It’s possible and I believe Amazon web hosting has an ssh server turned on by default. For cpanel I found this.

fsgl wrote on Sunday, February 08, 2015:

From the few glances at the Amazon cloud service, there appears to be more options than with hosts that deploy cPanel. Amazon permits the use of Windows while Linux must be used in cPanel.

Thanks for the link for SSH from the cPanel website. From following the other threads on hosted copies, I get the impression that the hosts will block the use of the command line external to the hosting site. If incorrect, please inform.

cmswest wrote on Sunday, February 08, 2015:

Ok, I see the Note entry on the link I posted which states that not all providers allow shell access.