0

I have xampp server running Codeiginiter 2.1.0 and a webserver with MySQL. I already have remote access with SQL-Front but when i put the same config in CI I recive this error:

A Database Error Occurred

Unable to connect to your database server using the provided settings.
Filename: C:\xampp\htdocs\mysite\trunk\system\database\DB_driver.php
Line Number: 124

database.php:

$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'myserver.com';
$db['default']['username'] = 'user_name';
$db['default']['password'] = 'pass';
$db['default']['database'] = 'database_name';
$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;

Someone know how to connect to remote database? Thanks for help!

1
  • The solution I found was downgrade the xampp to version 1.7.3 on windows. On Linux the problem was the same... Thanks for help! Commented Jan 19, 2012 at 12:23

3 Answers 3

1

I have used a mysql connect script like this. Connect script requires hostname, username and password. I am the administrator for the db, so could create or set the parameter values.

<?php

 // echo output below when called
 $con = mysql_connect($CFG->dbhost ,$CFG->dbuser, $CFG->dbpass);

 if (!$con){
    die('Could not connect: ' . mysql_error());
 }else{
    mysql_select_db($CFG->dbname, $con);
 }

?>
Sign up to request clarification or add additional context in comments.

Comments

0

In your /application/config/database.php file you can define an external database in the $db['default']['hostname'] setting.

You'll need to lookup what your external database address is through your web host most likely. Some hosts also restrict external access by IP address, so you might need to set that up also.

2 Comments

I have access to remote db.I have made a php script to connect with the same config and worked... The problem is with CI.
Have you tried turning on db_debug? If that doesn't show anything the next thing I would try is setting the $db['default']['port'] value.
0

Once you have the IP address that you wish to connect remotely from, follow these steps.

Log into cPanel.
Click the Remote MySQL button in the Databases section.
Enter the remote IP address in the Add Access Host section.
Click the Add Host button.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.