cant connect to database using cakephp and wampserver

前端 未结 1 808
闹比i
闹比i 2021-01-26 08:53

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

相关标签:
1条回答
  • 2021-01-26 09:14

    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

    0 讨论(0)
提交回复
热议问题