Cant access Database with Cake

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Cant access Database with Cake

Postby geoffcording » 04. April 2013 02:38

First, I am a newby to Apache/PHP etc.
I have installed XAMPP 1.1.1 on Windows XP SP3 32 bit and all appears to work fine. MySQL is running as a service, Apache and FIlezilla are not.
Mercury and Tomcat are not running. Control Panel is 3.1.0

I installed CakePHP 2.3.1 and ran the test page index.php. I have 2 warning messages related security.salt which I have not yet resolved but they do not
appear related to the basic issue. I get 4 messages showing status:
- version of PHP is 5.2.8 or higher
- tmp directory is writable
- FileEngine used for core aching
- database configuration file is present
Followed by the problem message:
- Cake is NOT able to connect to the database.
Database connection "Mysql" is missing, or could not be created.

I have searched the web with varying suggestions all appear to relate to an extension or PDO in some manner.

In my installation of XAMPP, localhost is set to point to xampp/htdocs. I cannot seem to use phpinfo.php to get more details as it is outside the localhost
directory base. (or I don't know enough to get around this). I have looked at php.ini and the following line IS include: extension=php_pdo_mysql.dll
I have seen web references to including PDO as well but also others stating PDO does not need to be included aver vers 5. something (mine is later).

The database can be accessed and data displayed using MySQL Workbench so I know it exists. MySQL reports it is using localhost:3306
My database is named TKD so I am unsure where the reference to connection "Mysql" is from.

So, my question is, can anyone suggest what the problem may be or what I do next, given my inexperience with Apache etc.

Thanks in anticipation...
geoffcording
 
Posts: 5
Joined: 04. April 2013 01:58
Operating System: Windows XP

Re: Cant access Database with Cake

Postby hackattack142 » 04. April 2013 03:59

Hello,

You can get to phpinfo by clicking the phpinfo() link on the main XAMPP page in the navigation panel.

As for the connection issue, I would make sure the user you configured with it has access (if your configured user has the % host, that will not allow you localhost access and you will need to make an identical DB user with the localhost host).
XAMPP Control Panel Developer
Latest CP: viewtopic.php?f=16&t=48932
hackattack142
 
Posts: 701
Joined: 20. May 2011 23:29
Operating System: Windows 7 Ultimate SP1 64-Bit

Re: Cant access Database with Cake

Postby geoffcording » 04. April 2013 05:28

Thanks for a response hackattack and I apologise for my lack of knowledge in advance. First, I cannot see any link to phpinfo on XAMPP control panel.
There are action buttons that take me to configure mysql and apache (I have checked php.ini) or to admin (for mysql it is to phpmyadmin which clearly shows the database exists and is accessible) but nothing that is evident to take me to phpinfo (the reason for going here is to check on the extensions according to several web entries). Re your connection comment, I am unsure what you are saying. All I know is that I can access the database through normal channels serviced by XAMPP (eg phpmyadmin or mysql workbench) but apparently not according to the CakePHP test page. Because the message refers to connection 'MySQL' it may be something as simple as not having the correct connection name but I do not know if this is the issue nor how to check it out.
geoffcording
 
Posts: 5
Joined: 04. April 2013 01:58
Operating System: Windows XP

Re: Cant access Database with Cake

Postby geoffcording » 04. April 2013 08:24

OK, I have resolved my problem and it turned out to be my lack of understanding. The message containing the partial sentence "Database connection "Mysql"" appears to be referring to the database.php datasource string 'Database/Mysql'. I had created a new entry in database.php in an attempt to avoid changing the default $default. However, I appear not to have told cake/php/mysql or someone that the database I wanted was something other than $default. So the code was using $default which points to a non-existant database name. I have reached this conclusion by removing my entry and changing the $default entry to refer to my database name and voila, it now works. I will explore how to change the database configuaration used at some time in the near future.
geoffcording
 
Posts: 5
Joined: 04. April 2013 01:58
Operating System: Windows XP

Re: Cant access Database with Cake

Postby hackattack142 » 04. April 2013 23:46

Good to hear.

When I said phpinfo() link on the XAMPP main page, I meant at http://localhost/xampp , not the control panel.
XAMPP Control Panel Developer
Latest CP: viewtopic.php?f=16&t=48932
hackattack142
 
Posts: 701
Joined: 20. May 2011 23:29
Operating System: Windows 7 Ultimate SP1 64-Bit


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 105 guests