I am trying to set up a MediaWiki site at work. I want it to be resilient across multiple sites, so what I am planning is 1 master database to take writes, and then a local slave database for each web install. This will mean I will have:
Server 1: MySQL Master
Server 2: MySQL Slave, Apache + MW
Server 3: MySQL Slave, Apache + MW
...
Server N: MySQL Slave, Apache + MW
What I want to happen, is if a site "goes dark", they will still have a local copy of the MW running in Read-Only mode, until it is able to contact the Master MySQL server again. I have set up the below configuration file on 1 of the slave hosts, which works fine. However, once I turn off the Master MySQL server to simulate a loss of connection, MW comes up with a DB error instead of just becoming Read-Only.
$wgDBservers = array(
array('host' => "10.10.10.10",
'dbname' => "db",
'user' => "####",
'password' => "####",
'type' => "mysql",
'flags' => DBO_DEFAULT,
'load' => 0),
array('host' => "localhost",
'dbname' => "db",
'user' => "####",
'password' => "####",
'type' => "mysql",
'flags' => DBO_DEFAULT,
'load' => 1)
);
Have I missed something from the configuration and this is something that I am able to do, or does it not work because it is not intended to work that way? Any help is appreciated.
This is not in any way "best practice" but in lieu of any other answer, I am posting it for anyone needing a quick work-around.
It is a PHP script that sits directly in the LocalSettings.php file and checks the status of the Master Database. The "proper" way to do it would probably be with an extension, but I don't have time to learn how to make one. You need to ensure that the user account that you are using to connect to MySQL, has Read-Only access to the slave database.
$wgDBSite_Master = array('host' => "<master ip>", 'dbname' => "<database>", 'user' => "<user>", 'password' => "<pass>", 'type' => "mysql", 'flags' => DBO_DEFAULT, 'load' => 0);
$Site_MasterTest = mysql_connect($wgDBSite_Master['host'], $wgDBSite_Master['user'], $wgDBSite_Master['password']);
if (!$Site_MasterTest) {
$wgReadOnly = 'Wiki failed to contact the Master server. Your site is currently running Dark. No edits will be saved.<br>Last Error: '.mysql_error();
$wgSiteNotice = $wgReadOnly;
$wgDBservers = array();
}
else {
$wgSiteNotice = 'Everything running normally, Captain';
$wgDBservers = array( $wgDBSite_Master );
}
$wgDBservers[] = array('host' => "localhost", 'dbname' => "<database>", 'user' => '<user>', 'password' => "<pass>", 'type' => "mysql", 'flags' => DBO_DEFAULT, 'load' => 1);
Related
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'root',
'password' => '000000',
'database' => 'cakephp',
'encoding' => 'utf8mb4',
'timezone' => 'UTC',
'cacheMetadata' => true,
my database in phpmyadmin in xampp is ok.
But stil the cakephp homepage says
CakePHP is NOT able to connect to the database.
Connection to database could not be established: SQLSTATE[HY000] [1045] Access denied for user 'my_app'#'localhost' (using password: YES)
I recently faced this issue and solved it by adding database configuration in config/app_local.php
As per Cakephp documentation:
The application skeleton features a config/app.php file which should
contain configuration that doesn’t vary across the various
environments your application is deployed in.
The config/app_local.php
file should contain the configuration data that varies between
environments and should be managed by configuration management, or
your deployment tooling
Reference:
CAKEPHP -> Configuration -> Configuring your Application
I'm getting this error "Use of undefined constant SIGKILL - assumed 'SIGKILL'" from my AJAX request, that starts this artisan command ->
Artisan::call('queue:work', [
'connection' => 'database',
'--memory' => '700',
'--tries' => '1',
'--timeout' => '35000',
'--queue' => 'updates'
]);
I'm using Laravel 5.7 as framework for application.
Jobs are managed from database, configuration ->
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 18000,
],
Problem appeared recently.. That is weird, because troubles wasn't here before and all this "system" worked just fine. Now worker get some jobs done just fine, but then it drops to error, and writes to table "failed_jobs" in DB this ->
ErrorException: PDOStatement::execute(): MySQL server has gone away in /srv/migration-xxxxxx-xxxx-xxxxxx/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
As DB I'm using Microsoft Azure MySQL DB. Microsoft specialist after consultation find nothing .. server is working correctly. Queries are just fine, not that big to fail.
Please help, don't know what to do, or what is wrong...
I am new into yii. I was transferring a premade yii website to my aws server. After adding the updated database info into protected/config/main.php I am getting this error. None of the references worked. Please help.
Site Url : http://multilingualbabies.com
Possible Issue:
1) PDO driver maybe its not enabled
2) your dsn connection not truth, make sure your configuration somthing like this:
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=dbName',
'username' => 'root',
'password' => 'yourPAssword',
'charset' => 'utf8',
];
Note: make sure mysql: is set in dsn.
3) make sure your mysql port is 3306, if other one try to change dsn by adding port like this 'dsn' => 'mysql:host=localhost;port=portNumber;dbname=dbName',.
Good Luck
I have created a freebie site for a local school where the students can have their own blog. I can get 150Mb MySQLdatabases at no charge through my hosts, but the WPMU install keeps maxing out. This is alot down to students not clearing spam!
I want to be able to bond more than one database (on different host IPs) to serve the installation. I've looked at HyperDB but can't get it to work.
$wpdb->add_database(array(
'host' => DB_HOST, // If port is other than 3306, use host:port.
'user' => DB_USER,
'password' => DB_PASSWORD,
'name' => DB_NAME,
));
$wpdb->add_database(array(
'host' => '***.***.***.51', // my second, blank database on a diff IP.
'user' => 'USER2', // a diff username.
'password' => DB_PASSWORD, // the same password as in the master config.php.
'name' => 'newdbase_2012', // my second database name.
));
Any help would be really, really appreciated in either getting this to work, or pointing out a new way of doing it!!!
This question already has answers here:
Database connection error in Yii
(2 answers)
Closed 9 years ago.
I've got a new domain & hosting but I can't connect to the new db.
What I tried:
'db'=>array(
'connectionString' => 'mysql:host=ascodcurro.com.mysql;dbname=ascodcurro_com',
'emulatePrepare' => true,
'username' => 'ascodcurro_com',
'password' => 'xxxx',
'charset' => 'utf8',
),
If I try localhost as always it works fine.
User info from host:
MySQL
server: ascodcurro.com.mysql
DB: ascodcurro_com
user: ascodcurro_com
pw: *****
PhpMyAdmin
PhpMyAdmin: https://dbadmin.one.com/
user: ascodcurro_com
pw: ******
During the initial startup and working with Yii, the first problem that I faced was connecting to the database.
I was getting a really weird error and I was not able to connect to my DB on my Mac OSX Mountain Lion on my XAMPP stack. After countless searches, I finally figured out a method that worked. This is the only way I am able to connect to my DB for Yii.
First check if you can connect to the database normally using the
default configuration by uncommenting the 'db' configuration in the
main.php file. Example :
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=ascodcurro_com',
'emulatePrepare' => true,
'username' => 'username',
'password' => 'pass',
'charset' => 'utf8',
'tablePrefix'=>'',
'enableProfiling'=>true,
'enableParamLogging'=>true,
),
However, if you are still not able to connect to the database even after this, as I wasn't able to connect to mine, try taking this approach :
Make a new php file and type :
<?php phpinfo() ?>
check that page out, find out where 'mysql' is located and find out the 'MYSQL_SOCKET' in it and note the location.
After noting the location down, try this as your 'db' connection string(for example, for me the location is "/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock") :
'connectionString' => 'mysql:unix_socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock;dbname=practice',
And the rest as the basic parameters that you use.
And then try connecting again.
Hopefully, that should connect you to your DB.
Regards,
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=basename',
'emulatePrepare' => true,
'username' => 'username',
'password' => 'pass',
'charset' => 'utf8',
'tablePrefix'=>'',
'enableProfiling'=>true,
'enableParamLogging'=>true,
),
its my config. You get any errors?