My online production environment: php and mysql are two independent servers. It does not work.
The local development environment: php and mysql are the same server. It can work well.
While running sql command, mysql that is connected to PDO is 127.0.0.1. However, my mysql is another server so that it does not work. The error is as follows:
Stack trace:
Next IlluminateDatabaseQueryException: SQLSTATE[HY000] [1045] Access denied for user 'treasure'@'127.0.0.1' (using password: YES) (SQL: insert into information (info_cate_id, title, desc, consumer_id, type, count, updated_at, created_at) values (3, Announcing soon!, Check who is lucky! Click to view: SAMSUNG MB-MP16DA/EU 16Gb Evo Micro SD Card, 10073, 2, 1, 2017-03-17 06:07:31, 2017-03-17 06:07:31)) in /data/www/yungou.ay/vendor/laravel/framework/src/Illuminate/Database/Connection.php:770
Stack trace:
@YangEndly that's an error with your configuration, you said it yourself, MySQL is on a separate server.
Update DB_HOST to your MySQL's external IP address.
@mrliptontea Thank you for your attention. I am certain that normal outside mysql address is set in my DB_HOST but error still occurs. My doubt: is it a bug that default connection of sql command in queue is 127.0.0.1?
@YangEndly if I understood right you are trying to set DB_HOST other than 127.0.0.1 but it sets you this as default ?
did you cleared your cache in the bootstrap folder ?
the configuration are probably cached..try:
php artisan clear-compiled
composer dump-autoload
if you do php artisan clear-compiled dont forget php artisan config:clear after :P
@edenreich I already tried to clear cache in bootstrap folder, and also tried
php artisan clear-compiled
composer dump-autoload
but still the same, do you have any other suggestions?
Thanks again...
this is class
class SendNotifyPurchase implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
private $product;
private $alias;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct($alias,$product)
{
$this->product=$product;
$this->alias=$alias;
}
/**
* Execute the job.
*
* @return void
*/
public function handle(JPushController $JPushController)
{
$alert = "Check who is lucky! Click to view: $this->product";
$title = 'Announcing soon!';
Information::create([
'info_cate_id'=>3,
'title'=>$title,
'desc'=>$alert,
'consumer_id'=>implode(' ',$this->alias),
'type'=>2,
'count'=>1,
]);
$JPushController->send_notify_one($alert,$this->alias,$title,'0');
}
}
The error message says Access denied for user 'treasure'@'127.0.0.1' - Is your db user treasure?
If yes, can you confirm that in the file where you set DB_USERNAME=treasure you also set DB_HOST to something else than 127.0.0.1?
Relevant command is php artisan config:clear.
Also, if run your job in the queue, run php artisan queue:restart so workers can pick up the updated config file.
@mrliptontea
Thank you so much for helping me solving the problem.
Most helpful comment
The error message says
Access denied for user 'treasure'@'127.0.0.1'- Is your db usertreasure?If yes, can you confirm that in the file where you set
DB_USERNAME=treasureyou also setDB_HOSTto something else than127.0.0.1?Relevant command is
php artisan config:clear.Also, if run your job in the queue, run
php artisan queue:restartso workers can pick up the updated config file.