Database remote host

mysql
9.1.x

#1

Hi guys!

I am trying to change the database to a remote host. I edit the config.php and modify the "dbhost" entry from localhost to a new IP.

However, when I try to access owncloud I get a 500 error.

(I migrated the data via mysqldump)

This is normal? How to solve this?

Thanks!


#2

See:


#3

The last record in data/owncloud.log

{"reqId":"FizrU1Bqwp+4DnDLudU\/","remoteAddr":"10.123.50.30","app":"PHP","message":"Module 'mysql' already loaded at Unknown#0","level":3,"time":"2017-03-24T14:40:36+00:00","method":"POST","url":"\/index.php\/login","user":"administrador"}

In the php-errors.log

Stack trace:
#0 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/html/owncloud/lib/private/DB/Connection.php(141): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBA in /var/www/html/owncloud/lib/private/DB/Connection.php on line 58
[25-Mar-2017 14:09:00 UTC] PHP Fatal error:  Uncaught exception 'Doctrine\DBAL\DBALException' with message 'Failed to connect to the database: An exception occured in driver: SQLSTATE[28000] [1045] Access denied for user 'owncloud'@'webdaily.filial.matriz.edu' (using password: YES)' in /var/www/html/owncloud/lib/private/DB/Connection.php:58
Stack trace:
#0 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(621): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/html/owncloud/lib/private/DB/Connection.php(141): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /var/www/html/owncloud/3rdparty/doctrine/dbal/lib/Doctrine/DBA in /var/www/html/owncloud/lib/private/DB/Connection.php on line 58
[25-Mar-2017 11:09:01 America/Sao_Paulo] PHP Warning:  Module 'gd' already loaded in Unknown on line 0
[25-Mar-2017 11:09:01 America/Sao_Paulo] PHP Warning:  Module 'mysql' already loaded in Unknown on line 0

The line draws my attention
owncloud'@'webdaily.filial.matriz.edu

Although this address exists on my local network, it has never been configured in owncloud.

Can you help me?

Thanks !!!


#4

The Failed to connect to the database: An exception occured in driver: means that you have some issues with the permission on the remote database host where the user or the owncloud host is not allowed to connect to the remote database.

How to configure this correctly heavily depends on your environment / setup and you might find infos how to do this when doing a research on the net. An few examples are e.g. shown at [1].

The Module 'xyz' already loaded in Unknown on line shows that you had messed up your PHP configuration and that you're loading modules twice or more. Those messages are unrelated to ownCloud but should be fixed anyway. You might will find additional information on this when putting this message into your favorite search engine.

[1]


#5

Thank you very much! Solved my problem.

It was a wrong parameter in the "grant privileges" command of mysql! :smile:


#6

Check whether you have configured the remote connection correctly or not. You need to add something like this

<?php

function getdb(){

$servername = "46.101.5.233"; // put your cloudways server IP here
$username = "qxxfumxxxbd";
$password = "xxxxbQxxmM";
$db = "qxxfumxxxbd";

try {

   $conn = mysqli_connect($servername, $username, $password, $db);

    //echo "Connected successfully";

   }

catch(exception $e)

   {

   echo "Connection failed: " . $e->getMessage();

   }

   return $conn;

}

Source: Set up remote mysql connection