Prestashop: 'Link to database cannot be established' - mysql

This is our first time moving a Prestashop Installation from one Domain to another and it has been one hell of a learning curve.
Steps we have taken so far:
Copied the database:
0) New database name: gamingco_ps, user gamingco_ps1
Changed ps_configuration
Changed the ps_shop_url (Domain/Domain SSL)
Amended htcacess to stop any redirects
CPANEL removed all temporary redirects
Changed the /home/gamingco/public_html/app/config/parameters.php :
<?php return array (
'parameters' =>
array (
'database_host' => 'localhost',
'database_port' => '',
'database_name' => 'gamingco_ps',
'database_user' => 'gamingco_ps1',
'database_password' => '{Password}',
'database_prefix' => 'pswy_',
'database_engine' => 'InnoDB',
'mailer_transport' => 'smtp',
'mailer_host' => '127.0.0.1',
'mailer_user' => NULL,
'mailer_password' => NULL,
'secret' => 'dva3atuoqjpqhb8xmjtfwjszkpbwaifombdlbg46qwygbi7e4mpyfgui',
'ps_caching' => 'CacheMemcache',
'ps_cache_enable' => false,
'ps_creation_date' => '2021-01-27',
'locale' => 'en-US',
'use_debug_toolbar' => true,
'cookie_key' => 'zml9yqgynwgixtb1e4c0xh8q8gjeynsp7arnovqw5dhpcthcyfpu89bx',
'cookie_iv' => 'qsembkbmpfbnk5bf3hhxjg3sw1laaa06',
'new_cookie_key' => 'def00000acce4699cd116debb37dc5533dfd6ff201153a61ac3446801d772207548a0f44596a7a01939e9f753e4290f3735373a25516e62b2118322ec7f7cd64e3b347ee',
),
);
We are now receiving error 500 without debug mode and with debugmode we are met with:
Link to database cannot be established: SQLSTATE[28000] [1045] Access denied for user 'gamingco_ps1'#'localhost' (using password: YES)
at line 136 in file classes/db/DbPDO.php
131. public function connect()
132. {
133. try {
134. $this->link = $this->getPDO($this->server, $this->user, $this->password, $this->database, 5);
135. } catch (PDOException $e) {
136. throw new PrestaShopException('Link to database cannot be established: ' . $e->getMessage());
137. }
138.
139. $this->link->exec('SET SESSION sql_mode = \'\'');
140.
141. return $this->link;```
DbPDOCore->connect - [line 330 - classes/db/Db.php]
DbCore->__construct - [line 241 - classes/db/Db.php] - [4 Arguments]
DbCore::getInstance - [line 47 - config/alias.php]
pSQL - [line 1336 - classes/shop/Shop.php] - [1 Arguments]
ShopCore::findShopByHost - [line 337 - classes/shop/Shop.php] - [1 Arguments]
ShopCore::initialize - [line 118 - config/config.inc.php]
require - [line 27 - index.php] - [1 Arguments]
I gone through all the steps again and I cannot seem to identify where the error maybe.

Error is pretty straighforward here, Prestashop cannot connect to database.
Things to check:
Make sure your var/cache/prod directory does not contain any cache file from previous installation as it can lead to old DB connection with old credentials.
Double check DB data in parameters.php, carefully look for data correctness (case sensitive, correct DB host / port etc.)
If none of above helps, try connecting your box from ssh and check direct db connection from there with :
mysql -u{username} -p{password} {database name}
and post the result.

Related

Use of undefined constant SIGKILL - assumed 'SIGKILL' in Laravel 5.7 queue

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

Yii2 unit testing :: Access denied for user 'something'#'localhost' (using password: NO)

When creating automated testing in unit testing. I get this error.
My code is in unit test
function testSavingUser()
{
$user = new User();
$user->auth_key='value';
$user->password_hash='value';
$user->password_reset_token='value';
$user->email='value';
$user->status=1;
$user->first_name='value';
$user->last_name='value';
$user->image='value';
$user->role_id=1;
$user->created_date='2016-08-31 16:57:10';
$user->updated_date='2016-08-31 16:57:10';
$user->save();
$this->assertEquals('Miles Davis', $user->getFullName());
$this->tester->seeInDatabase('users', ['name' => 'Miles', 'surname' => 'Davis']);
}
This my config file
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/web.php'),
//require(__DIR__ . '/main-local.php'),
[
'id' => 'app-tests',
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=' . getenv('DB_HOST'). ';dbname=' . getenv('DB_NAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASSWORD'),
'charset' => 'utf8',
],
]
]
);
return $config;
In functional.suite.yml
class_name: FunctionalTester
modules:
enabled:
- Yii2:
configFile: 'config/test.php'
When trying to execute my test with codecept run it shows error like this
[yii\db\Exception] SQLSTATE[28000] [1045] Access denied for user 'something'#'localhost' (using password: NO)
Possible reasons of error:
Provided credentials are incorrect or mixed with each other. Check them accurately for typos, etc.
Environment variables are not accessed or extracted correctly with getenv calls. Check if the keys are right and make sure that correct values returned (you can use something like var_dump).
User has no privileges to access this database. You can see how to set it for example in this related question.

Codeigniter Cpanel Mysql Database Setup

I have successfully pushed a codeigniter project to a cpanel console.
Everything seems to be working fine except the database connection.
I believe i have the settings correct but i could be wrong.
Below is my database.php script:
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'instadri_insta',
'password' => 'BL9w;K;ds9MR',
'database' => 'instadri_ver',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => TRUE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I have the errors below:
A PHP Error was encountered
Severity: Warning
Message: mysqli::real_connect(): (HY000/1044): Access denied for user
'instadri_insta'#'localhost' to database 'instadri_ver'
Filename: mysqli/mysqli_driver.php
Line Number: 202
Backtrace:
File: /home/instadri/application/controllers/Welcome.php Line: 10
Function: __construct
File: /home/instadri/public_html/index.php Line: 319 Function:
require_once
I also get :
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by
(output started at /home/instadri/system/core/Exceptions.php:272)
Filename: core/Common.php
Line Number: 568
Backtrace:
File: /home/instadri/application/controllers/Welcome.php Line: 10
Function: __construct
File: /home/instadri/public_html/index.php Line: 319 Function:
require_once
And Finally :
Unable to connect to your database server using the provided settings.
Filename: controllers/Welcome.php
Line Number: 10
I have taken care of the above.
The new issue now is the smarty template file loading.
I have a controller that does this :
$this->smarty->view('front-theme/index.tpl', $data );
But i get this error:
Unable to load the requested file:
front-theme/index.tpl
My cpanel directory structure is:
public_html
- index.php
application
system public
-_template
-_cache
-front-theme
I had the same problem but I have solved it.
Simply upload your CI files to the public html folder, every thing in the CI folder should be uploaded together. so when you open the public folder it should filled with the CI files.
Leave your db settings the same way, but cross-check the values you entered for validity. and finally go to the config.php file and check the base url variable and change to your url link name.
That's it!

vagrant : chef_solo | how i can change log path from mysql server and mongodb?

I'm working with vagrant and chef .
As far as everything goes , only when I use the Logpath of mysql and mongodb change in the vagrant file , I get an error.
if anyone here has a tip and can help me would be happy.
In Vagrantfile I have stated so ...
:mysql => {
:server_root_password => 'password',
:server_debian_password => 'password',
:server_repl_password => 'password',
:allow_remote_root => true,
:log_dir => "/vagrant/www/logs/mysql",
:tunable => {
:log_slow_queries => "/vagrant/www/logs/mysql/slow.log",
:log_error => true,
:log_warnings => true
}
},
:mongodb => {
:logpath => "/vagrant/www/logs/mongodb"
},
================================================================================
Error executing action `create` on resource 'directory[/vagrant/www/logs/mysql]'
================================================================================
Errno::EPERM
------------
Operation not permitted - /vagrant/www/logs/mysql
Resource Declaration:
---------------------
# In /tmp/vagrant-chef/chef-solo-1/cookbooks/mysql/recipes/server.rb
117: directory path do
118: owner 'mysql' unless platform?('windows')
119: group 'mysql' unless platform?('windows')
120: action :create
121: recursive true
122: end
123: end
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef/chef-solo-1/cookbooks/mysql/recipes/server.rb:117:in `block in from_file'
directory("/vagrant/www/logs/mysql") do
provider Chef::Provider::Directory
action [:create]
retries 0
retry_delay 2
path "/vagrant/www/logs/mysql"
recursive true
cookbook_name :mysql
recipe_name "server"
owner "mysql"
group "mysql"
mode 493
end
[2013-10-31T01:03:09-07:00] DEBUG: Re-raising exception: Errno::EPERM - directory[/vagrant/www/logs/mysql] (mysql::server line 117) had an error: Errno::EPERM: Operation not permitted - /vagrant/www/logs/mysql
This line is the key problem: Operation not permitted - /vagrant/www/logs/mysql
which means it does not allow user to create directory under this path. Please check if user mysql is privileged to access directory /vagrant/www/logs. Maybe you need +x on /vagrant
First, I would not advise using this -- slow log writes will slow down most databases and I wouldn't want to do that to myself.
Anyhow, permissions on vagrant shared folders can be a bit tricky -- in some, if not many, cases you need to set owner / permission from the vagrantfile. This is a bit tricky for /vagrant but you could map another folder if you really don't want to vagrant ssh into the server to read the logs. To do so:
config.vm.synced_folder "logs", "/logs", :mount_options => ['dmode=777', 'fmode=777']
777 is probably overkill but you get the idea.

Kohana - Database_Exception [ 2 ]: mysql_connect() 2

I am trying to setup my database config as demonstrated here: http://kowsercse.com/2011/09/04/kohana-tutorial-beginners/
I have cut and pasted the database.php with my mysql credentials. I then get an error which I fixed by renaming the file to Database.php. the next issue is that my credentials don't change no matter what I put in.
The error shows:
Database_Exception [ 2 ]: mysql_connect() [function.mysql-connect]: Access denied for user 'ivanh'#'localhost' (using password: NO)
MODPATH/database/classes/Kohana/Database/MySQL.php [ 67 ]
62 catch (Exception $e)
63 {
64 // No connection exists
65 $this->_connection = NULL;
66
67 throw new Database_Exception(':error',
68 array(':error' => $e->getMessage()),
69 $e->getCode());
70 }
71
72 // \xFF is a better delimiter, but the PHP driver uses underscore
So no matter what I insert, username, host and password values do not change.
My code in Database.php is then copied from: http://kohanaframework.org/3.3/guide/database/config
firstly with my own database values then after as is. With no luck.
Other info: I'm creating this on a shared unix host.
Kohana 3.1.4: Database_Exception [ 2 ]: mysql_connect(): Access denied seems like a similar issue without a resolution.
Any help would be great, thanks.
Try These Steps:
Step 1:
Go to bootstrap.php
path- kohana\application\bootstrap.php
Un-comment the below line for database access
'database' => MODPATH.'database', // Database access
Step 2:
Go to Your config folder,
create the database.php file if not created, with below codes by giving your MySql credential
Path: kohana\application\config\database.php
Notes: First create a database in your Mysql
If the problem is not solved check your MySql settings too..there may be a error
<?php defined('SYSPATH') OR die('No direct access allowed.');
return array
(
'default' =>
array
(
'type' => 'MySQL',
'connection' => array(
/**
* The following options are available for MySQL:
*
* string hostname server hostname, or socket
* string database database name
* string username database username
* string password database password
* boolean persistent use persistent connections?
* array variables system variables as "key => value" pairs
*
* Ports and sockets may be appended to the hostname.
*/
'hostname' => 'localhost',
'database' => 'CHANGE YOUR DATABASE NAME HERE',
'username' => 'CHANGE YOUR USER NAME HERE',
'password' => 'CHANGE YOUR PASSWORD HERE',
'persistent' => FALSE,
),
'table_prefix' => '',
'charset' => 'utf8',
),
'remote' => array(
'type' => 'MySQL',
'connection' => array(
/**
* The following options are available for PDO:
*
* string dsn Data Source Name
* string username database username
* string password database password
* boolean persistent use persistent connections?
*/
'dsn' => 'mysql:host=localhost;dbname=CHANGE YOUR DATABASE NAME HERE',
'username' => 'CHANGE YOUR USER NAME HERE',
'password' => 'CHANGE YOUR PASSWORD HERE',
'persistent' => FALSE,
),
/**
* The following extra options are available for PDO:
*
* string identifier set the escaping identifier
*/
'table_prefix' => '',
'charset' => 'utf8',
'caching' => FALSE,
),
);
I am going to make the following assumptions:
You are consequently writing "Database.php" because the file in APPPATH/config containing the code you copied does indeed start with a capital letter.
You haven't changed the config reader.
Database::instance() will request a config array from the Kohana::$config if none is supplied. Config_File::load() will then loop through all found /config/database.php's found in APPPATH, enabled modules and SYSPATH.
Unix filesystems are case sensitive, notice the lowercase 'd' Kohana is looking for versus your uppercase 'D'.
If you did name it 'database.php' and not 'Database.php', click on 'Environment' and then 'Included files' on the error page and make sure it is included. If it's not, do some backtracking and try to find out when things stop behaving as they should, followed by why.
Edit: I don't know how I missed the "renamed it to Database.php" part, but that did not fix anything.