0

I am a rails developer working with a client who absolutely demands that I fix their old codeigniter site, then port it into rails (don't ask why, that's a whole different question). Anyway, they seem to have two databases listed in their database.php file, one points to a MySQL DB that I can access via godaddy, no prob. The other, which is the one that has all of the functionality(reading, writing editing etc) has a localhost hostname. There is no record of the tables or db names of this second db in their godaddy account and they have no way to contact the developer that wrote this app or any documentation. And coincidentally that is the DB that I need to modify, as well as port over to the new rails app. Am I just totally missing something obvious here?

$active_group = "default";
$active_record = TRUE;
$db['default']['hostname'] = "hostedresource.com";
$db['default']['username'] = "uname";
$db['default']['password'] = "pword"; 
$db['default']['database'] = "database";
$db['default']['dbdriver'] = "mysqli";
$db['default']['dbprefix'] = "";
$db['default']['active_r'] = TRUE;
$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";

// Admin group (for adding and deleting articles)
$db['admin']['hostname'] = "localhost";
$db['admin']['username'] = "username";
$db['admin']['password'] = "password";
$db['admin']['database'] = "other_database";
$db['admin']['dbdriver'] = "mysql";
$db['admin']['dbprefix'] = "";
$db['admin']['active_r'] = TRUE;
$db['admin']['pconnect'] = TRUE;
$db['admin']['db_debug'] = TRUE;
$db['admin']['cache_on'] = FALSE;
$db['admin']['cachedir'] = "";
$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

and heres the mysql_connect call in one of the task files

$conn = mysql_connect("localhost", "username", "password"); mysql_select_db("other_database");
3
  • posting the database.php would be helpful Commented Jul 11, 2013 at 22:02
  • 1
    can you see that db ?? !!! Commented Jul 11, 2013 at 22:07
  • Posted, and yes I can. That's whats confusing me Commented Jul 11, 2013 at 22:08

1 Answer 1

2

is godaddy hosting the site? I'm going to guess not, because I know godaddy keeps all web and mysql hosting separate.

I've had a simliar situation where I was accessing an old go-daddy sql db, but also using a new one (which was local to the VM i was using from hostgator) basically the same code as you have above(except I used the new mysqli Extension like you are supposed to)

localhost in this instance means that the DB is on the same machine running the PHP. So The localhost db should be located on the machine your web-server is running off of If you have SSH access to your server, you should be able to run mysql from the shell and get the info you need.

you can also just try yoururl/phpmyadmin ... a lot of servers come with it preinstalled...

now, I just hope you have the credentials :-p

=======

now that you are getting

#2013 - Lost connection to MySQL server at 'reading initial communication packet', system error: 110

typically this means your local ip (your computer) isn't on the access control list for PHPmyadmin.

If your host has a control panel, you should be able to add your ip address to the Allowable Hosts section in the phpmyadmin settings (most control panels like cpanel have this).

try yoururl/cpanel or yoururl:2083 maybe we will get lucky

if not you need to find the phpmyadmin ini file, on my server it is located at /etc/httpd/conf.d/phpMyAdmin.conf but that's going to depend on your set up.

in the ini file

#obviously the path is dependent on your setup

<Directory "/usr/share/phpMyAdmin"> 
Options FollowSymLinks
AllowOverride None
Order allow,deny
#put your ip address here
Allow from 111.111.111.111
</Directory>
Sign up to request clarification or add additional context in comments.

2 Comments

I went for your suggestion, got somewhere, then got this gem: #2013 - Lost connection to MySQL server at 'reading initial communication packet', system error: 110
this is good! I'm guessing you were able to get to phpmyadmin...almost updating my answer now :)

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.