0

I am using 64bit WampServer and cakephp 3.2 and win10. I have a new computer and need to transfer a cakephp project. There is a user Root with all privileges, with no password and database 'aptutori_apt4' n exists on phpmyadmin

The project loads if it doesnt need the database but this is what I get error: sqlstate[hy000] [1049] unknown database 'aptutori_apt4' I cant connect the database!

Is the host setting wrong ?

 'Datasources' => [
        'default' => [
            'className' => 'Cake\Database\Connection',
            'driver' => 'Cake\Database\Driver\Mysql',
            'persistent' => false,
            'host' => 'localhost',
          
            //'port' => 'non_standard_port_number',
            'username' => 'root',
            'password' => '',
            'database' => 'aptutori_apt4',
            'encoding' => 'utf8',
            'timezone' => '+11:00',
            'flags' => [],
            'cacheMetadata' => true,
            'log' => false,

It is the same settings as my other computer on phpmyadmin and app.php. The new computer shows on phpmyadmin under database tab Server:Mysql:3308

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
atown99
  • 109
  • 12

1 Answers1

2

I think your problem is that recently mariaDB became the default database in WAMPServer, so therefore mariaDB is using port 3306 (the default for almost everything MySQL) and MySQL is listening on port 3308

However, if you want to use MySQL, the simple solution would be to swap the default database in WAMPServer, and of course there is a tool for that on the WAMPManager Menus.

Right-click Wampmanager icon -> Tools -> Invert default DBMS MariaDB <-> MySQL

Now MySQL will use port 3306 and mariaDB will use port 3307.

Now your cake config should work and find the correct DBMS on port 3306 and therefore the database you have created in there.

This is the safest solution as when you move code to a live server it will almost definitely have its MySQL/mariaDB configured to use port 3306 and you wont need to change anything in your config.

Alternatively

You could put the port number that MySQL is Listening on in this param

'port' => '3308',

But you will almost definitely have to change this when the site get moved to a Live Server, and then you dev code and your live code will be different, unless you remember not to transfer this file after the first time.

Oh and remember you can reverse this change in default database, just go back to the menus and the menu you used last time should say

Right-click Wampmanager icon -> Tools -> Invert default DBMS MySQL <-> MariaDB

Do that and you are back to mariaDB using port 3306

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
  • Sounds like a good answer. before trying this, is there a setting I could change in the setup as above ? could i simply use Maria instead of Mysql if the database can be used by each other? – atown99 Jul 10 '20 at 10:27
  • You could use mariaDB ( find out first what is used on the server where you will implement this site) but you sound like you already created the database on MySQL – RiggsFolly Jul 10 '20 at 13:19
  • You can export the DB from MySQl and restore it to MariaDB if you want – RiggsFolly Jul 10 '20 at 13:20
  • the problem has been fixed with the solution provided. – atown99 Jul 11 '20 at 02:29