gpt4 book ai didi

php - 宝塔盒子无法使用MySQL

转载 作者:行者123 更新时间:2023-11-30 00:42:15 24 4
gpt4 key购买 nike

这是我第一次运行宝塔盒子。我有一个 PHP 应用程序。它需要使用MySQL数据库。我已经上传了所有代码。我还创建了安全隧道连接。但是当我尝试连接到数据库时,出现了一些问题。我无法加载数据库。它甚至没有给我任何错误。

这是我的代码

$this->load->database();
echo 'here';

$db['default']['hostname'] = 'tunnel.pagodabox.com:3306';
$db['default']['username'] = 'xxxx';
$db['default']['password'] = 'xxxx';
$db['default']['database'] = 'blog';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
$db['default']['port'] = 45000;

顺便说一句,我的 MySQL 数据库运行在端口 3306 上,隧道运行在 45000 上。

最佳答案

假设您正在尝试从本地计算机连接到 pagodabox 中的 mysql 数据库。

1.从桌面保护数据库隧道。如果连接成功,您可能会得到类似的信息。

Tunnel Established!  Accepting connections on :
-----------------------------------------------

HOST : 127.0.0.1 (or localhost)

PORT : 3307

USER : (found in pagodabox dashboard)

PASS : (found in pagodabox dashboard)

2.本地codeigniter应用连接到pagodabox mysql

<罢工>

<罢工>
    $this->load->database();
echo 'here';

<罢工>

$db['default']['hostname'] = '127.0.0.1';

$db['default']['username'] = 'xxxx';

$db['default']['password'] = 'xxxx';

$db['default']['database'] = 'blog';

..

..

$db['default']['port'] = 3307; // This one matches with Port displayed above.
</pre>

要查看错误,请打开index.php文件并设置错误报告E_ALL

if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;

case 'testing':
case 'production':
error_reporting(0);
break;

default:
exit('The application environment is not set correctly.');
}
}
error_reporting(E_ALL);

关于php - 宝塔盒子无法使用MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21672882/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com