0

I downloaded the CodeIgniter project from server and I want to run it in my localhost, I got an error when I run it. Does anyone know what is the problem? I used MAMP on Mac.

Here is my db error:

ErrorException [ Fatal Error ]: Unable to connect to your database server using the provided settings. / Filename: core/Loader.php / Line Number: 346

Here is 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;
halfer
  • 19,824
  • 17
  • 99
  • 186
  • possible duplicate of [CodeIgniter: Unable to connect to your database server using the provided settings Error Message](http://stackoverflow.com/questions/7254049/codeigniter-unable-to-connect-to-your-database-server-using-the-provided-settin) – Rahil Wazir Oct 01 '14 at 20:16
  • It doesn't look like you've changed the default database settings. Your database will have a username and password - have you installed MySQL? If so, you can create a user through phpMyAdmin, or on the console if you prefer. – halfer Oct 01 '14 at 20:35
  • @halfer I used MAMP should I use MySQL? –  Oct 01 '14 at 21:26
  • 1
    @RahilWazir it i snot dublicate I saw it before it didnot help, if you have suggetion insted of searching to find a issue let me know other wise I already check stackoverflow answers –  Oct 01 '14 at 21:28
  • Ah, good point @EL - you have MySQL already (it's in the MAMP package). Do you have the root user and password (which you probably would have been asked for when installing)? Put them in `$db['development']['username']` and `$db['development']['password']` and try again. – halfer Oct 01 '14 at 21:33
  • 1
    (Btw, using the root credentials is not ideal, but since it's a development machine it's not terrible either. I would recommend you search on how to create a new MySQL user though - you can do it in phpMyAdmin, as I said above). – halfer Oct 01 '14 at 21:39

2 Answers2

0

You are not connected to MySQL Server at all. Please make sure that MySQL is installed on your machine.Second , check if the MySQL Service is running. Third , make sure about access information that you have filled on Database.php file.

Hatem
  • 349
  • 2
  • 12
  • I used Mamp do I need MySQL also? –  Oct 01 '14 at 21:26
  • MySQL comes built-in with Wamp , but you need to check if MySQL service is running through Wamp. Search about Wamp Tray icon , if it is not green it means that one of your services in not working. Click right on it , then click on (Start All Services) – Hatem Oct 02 '14 at 03:31
0

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. I would double check user/password using terminal (use MySQL from prompt, connect, use 'bmgr', select from a table). 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

Marius
  • 190
  • 1
  • 9