Database exists but returns an error saying “Unknown Database”

前端 未结 1 1940
忘了有多久
忘了有多久 2021-01-13 07:52

I installed WAMP server few hours ago into my Windows 10 64-bit computer. I used phymyadmin to create a d

1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-13 08:28

    In the newer versions of Wampserver, the port for MySQL has changed from 3306 to 3308 (you can see it in your first screenshot). You will need to update your connection to specify that port. Otherwise you will be hitting the MariaDB installed with WAMP which does not have that database within it.

    define('DB_SERVER', 'localhost');
    define('DB_USERNAME', 'root');
    define('DB_PASSWORD', '');
    define('DB_NAME', 'testdb');
    define('DB_PORT', 3308);
    
    $link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, DB_PORT);
    

    As pointed out in the comments, it is also possible to make MySQL your default database which would also solve your problem. You can get the instructions from the DBA Stack Exchange site.

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