问题描述
这是我们第一次将 Prestashop 安装从一个域转移到另一个域,这是一个非常艰难的学习曲线。
我们目前采取的步骤:
复制数据库: 0) 新数据库名称:gamingco_ps,用户gamingco_ps1
- 更改了 ps_configuration
- 更改了 ps_shop_url(域/域 SSL)
- 修改了 htcacess 以停止任何重定向
- CPANEL 删除了所有临时重定向
- 更改了 /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',),);
我们现在在没有调试模式的情况下收到错误 500,在使用 debugmode 时我们会遇到:
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]
我再次执行了所有步骤,但似乎无法确定错误在哪里。
解决方法
这里的错误非常简单,Prestashop 无法连接到数据库。
检查事项:
-
确保您的 var/cache/prod 目录不包含之前安装中的任何缓存文件,因为它可能会导致使用旧凭据建立旧数据库连接。
-
仔细检查parameters.php中的DB数据,仔细寻找数据的正确性(区分大小写,正确的DB主机/端口等)
如果以上都没有帮助,请尝试从 ssh 连接您的盒子并从那里检查直接数据库连接:
mysql -u{username} -p{password} {database name}
并发布结果。