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...
Related
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 want to use SQLite for PHPunit tests. We are using the mysql driver, so we have created our migrations based on that... meaning we are using nullables for default values. MYSQL doesn't care about this. SQLite, apparently, does.
Migrations:
Schema::table('users', function ($table) {
$table->string('username', 132)->nullable();
TestCase snippet: configuring phpunit environment
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => ''
]
Running phpunit outputs:
Cannot add a NOT NULL column with default value NULL
I noticed there was a "STRICT" mode for mysql in the database.php configuration file that you can set to false which handles invalid or missing data types:
'mysql' => [
'driver' => 'mysql',
...
'strict' => false,
],
So I started looking for a strict mode for SQLite and found Strict Mode here, tried setting PRAGMA strict=ON; to off
$app['config']->set('database.connections.testbench', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
'strict' => false
]
But this did not fix it.
Is there a way to set SQLite to ignore nullable() values set in migrations (aimed at mysql configurations) so I can run my unit tests quickly with SQLite in memory?
My alternatives are:
remove all nullable() options for migrations and add defaults, which will take forever
use mysql instead of sqlite, which will be much slower
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);
I just upgraded my Laravel install from 4.1.(something) to 4.2.7 using the steps recommended here: http://laravel.com/docs/upgrade
Now I'm getting this error on every page:
PDOException (2002)
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '' (111)
MySQL is not running locally, but it's not supposed to be. I don't have any configuration for connecting to local MySQL, my development SQL server is remote. Why is it trying to connect to local?
Is there some config change that isn't mentioned in the upgrade guide? Everything was peachy in 4.1.
From my app/config/database.php file:
'default' => 'mysql',
...
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'myrealdb.us-east-1.rds.amazonaws.com',
'database' => 'myrealdbname',
'username' => 'myrealuser',
'password' => 'myrealpass',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'database_port' => '3306',
'unix_socket' => '',
),
...
);
I tried php artisan clear-compiled and php artisan dump-autoload just in case. No effect.
Edit: I submitted a fix for this that has been merged into the 4.2 branch. You shouldn't have to worry about this error anymore.
I got it! This appears to be a change in the way Laravel uses the database configuration, I hope this answer helps others.
The short version is: if your connection is configured like mine (in the question), delete the unix_socket entry from the array.
Previously, I always copied and edited the default entries in the connections array, leaving in the unix_socket parameter as empty. Apparently now there's a check that assumes if unix_socket is present, it should use a socket DSN string. The empty string in my config passed the check. You can see how this happens in /vendor/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php. The functions getDsn, getSocketDsn, and getHostDsn tell the story.
Pasted because this will eventually change:
protected function getDsn(array $config)
{
return isset($config['unix_socket']) ? $this->getSocketDsn($config) : $this->getHostDsn($config);
}
...
protected function getSocketDsn(array $config)
{
extract($config);
return "mysql:unix_socket={$config['unix_socket']};dbname={$database}";
}
...
protected function getHostDsn(array $config)
{
extract($config);
return isset($config['port'])
? "mysql:host={$host};port={$port};dbname={$database}"
: "mysql:host={$host};dbname={$database}";
}
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?