简体   繁体   English

设置现有CodeIgniter的数据库连接错误

[英]Database connection error for set up existing CodeIgniter

I downloaded the CodeIgniter project from server and I want to run it in my localhost, I got an error when I run it. 我从服务器下载了CodeIgniter项目,我想在我的本地主机中运行它,运行它时出现错误。 Does anyone know what is the problem? 有谁知道这是什么问题? I used MAMP on Mac. 我在Mac上使用过MAMP。

Here is my db error: 这是我的数据库错误:

ErrorException [ Fatal Error ]: Unable to connect to your database server using the provided settings. ErrorException [致命错误]:无法使用提供的设置连接到数据库服务器。 / Filename: core/Loader.php / Line Number: 346 /文件名:core / Loader.php /行号:346

Here is database.php 这是database.php

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$active_group = ENVIRONMENT;
$active_record = TRUE;

$db['development']['hostname'] = 'localhost';
$db['development']['username'] = 'fake';
$db['development']['password'] = 'fake';
$db['development']['database'] = 'bmgr';
$db['development']['dbdriver'] = 'mysqli';
$db['development']['dbprefix'] = '';
$db['development']['pconnect'] = TRUE;
$db['development']['db_debug'] = TRUE;
$db['development']['cache_on'] = FALSE;
$db['development']['cachedir'] = '';
$db['development']['char_set'] = 'utf8';
$db['development']['dbcollat'] = 'utf8_general_ci';
$db['development']['swap_pre'] = '';
$db['development']['autoinit'] = TRUE;
$db['development']['stricton'] = FALSE;

$db['staging']['hostname'] = 'localhost';
$db['staging']['username'] = 'fake';
$db['staging']['password'] = 'fake';
$db['staging']['database'] = 'bmgr1';
$db['staging']['dbdriver'] = 'mysqli';
$db['staging']['dbprefix'] = '';
$db['staging']['pconnect'] = TRUE;
$db['staging']['db_debug'] = TRUE;
$db['staging']['cache_on'] = FALSE;
$db['staging']['cachedir'] = '';
$db['staging']['char_set'] = 'utf8';
$db['staging']['dbcollat'] = 'utf8_general_ci';
$db['staging']['swap_pre'] = '';
$db['staging']['autoinit'] = TRUE;
$db['staging']['stricton'] = FALSE;

You are not connected to MySQL Server at all. 您根本没有连接到MySQL Server。 Please make sure that MySQL is installed on your machine.Second , check if the MySQL Service is running. 请确保您的计算机上已安装MySQL。其次,检查MySQL服务是否正在运行。 Third , make sure about access information that you have filled on Database.php file. 第三,确保有关您在Database.php文件中填写的访问信息。

no offense, but just for my curiosity is your database located on the same server? 没有冒犯,但出于我的好奇心,您的数据库位于同一服务器上吗? I see you use 'localhost' but database may also be on a different machine. 我看到您使用的是“ localhost”,但数据库也可能位于其他计算机上。 I would double check user/password using terminal (use MySQL from prompt, connect, use 'bmgr', select from a table). 我将使用终端再次检查用户名/密码(从提示符使用MySQL,连接,使用“ bmgr”,从表中选择)。 If this works it means your file is not correctly edited. 如果这样做有效,则意味着您的文件没有正确编辑。 If it doesn't you may be pointing to the wrong machine and/or you have a firewall issue and/or user permission issue 如果不是,则可能是您指向错误的计算机,并且/或者您遇到了防火墙问题和/或用户权限问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM