Multiple MySQL databases for Wordpress Multisite - mysql

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!!!

Related

CDbConnection failed to open the DB connection Yii after moving to aws

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

Unable to connect to localhost database

This question has already been asked multiple times but none of the answers have helped me.
I am upgrading to Drupal 8 and to do so, I need to specify the login credentials for my Drupal 7 database.
SQLSTATE[HY000] [2002] No connection could be made because the target
machine actively refused it.
I can access the database perfectly fine to my SQL server is 100% running.
I have checked the credentials inside settings.php and it says the following:
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'karma-living.dev',
'username' => 'root',
'password' => '',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
So I copied above but I still get the error message above (yellow box).
See following image:
Does anyone have any suggestions? Thank you in advance.
The Acquia Desktop says your database name is "karma_dev", but you've entered "karma-living.dev" as the name for Drupal, so there is an inconsistency.

Site Resilient MediaWiki Install

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);

DB connection Yii Framework [duplicate]

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?

CakePHP 2.1 doesn't work on localhost

I deployed my app on a remote host and everything works as expected. But when I try to test my code on localhost, it gives me the following error, without any change to the code working on the host:
Fatal error: Class 'AppHelper' not found in [path]
I am using CakePHP 2.1 and MySQL as my default datasource.
I connect to my local database just like to the remote one (with authentication changes):
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'database',
'prefix' => '',
'encoding' => 'utf8',
);
Why isn't this working on my localhost? Thank you
Two possible things:
either you didnt know about the AppHelper requirement for 2.1:
http://book.cakephp.org/2.0/en/appendices/2-1-migration-guide.html
or you forget to declare the helper at the very top of your class:
App::uses('AppHelper', 'View/Helper');
Although the second one is highly unlikely if you are not running any unit tests.
So my bet is on the first one.