本文介紹了我該如何解決這個“警告:mysqli_connect():(HY000/1049):未知數據庫"?問題?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我下載了一個事件管理軟件并安裝了 wamp 服務器.一切都很好,但是當我嘗試注冊該網站時,它向我顯示了這個
I downloaded an Event management software and install wamp server. Everything is fine but when I try to sign up into the website, it is showing me this
( ! ) Warning: mysqli_connect(): (HY000/1049): Unknown database 'eventmanagmnt' in C:wamp64wwwEmspconnection.php on line 2
Call Stack
# Time Memory Function Location
1 0.0507 403176 {main}( ) ...Login.php:0
2 0.1265 404264 include( 'C:wamp64wwwEmspconnection.php' ) ...Login.php:2
3 0.1266 404264 mysqli_connect ( ) ...connection.php:2
推薦答案
WAMP 的新版本似乎同時安裝了 MySQL 和 MariaDB.而當我通過phpMyAdmin登錄時,我看到MySQL使用的是3308端口.
New versions of WAMP seems to install both MySQL and MariaDB. And when I logged in through the phpMyAdmin, I saw that the MySQL is using the port 3308.
因此,在我的 PHP 代碼中,我沒有僅使用 localhost
作為我的數據庫主機名,而是像這樣添加了端口:localhost:3308
并且它起作用了.
So in my PHP code, instead of using just localhost
for my database hostname, I added the port to it like this: localhost:3308
and it worked.
$db = new mysqli('localhost:3308', 'root', 'password', 'db_name');
這篇關于我該如何解決這個“警告:mysqli_connect():(HY000/1049):未知數據庫"?問題?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!