$conn = new Mongo("mongodb://admin:admin@localhost:27017/local"); ///這個就是第11行
這麼寫完之後報錯
( ! ) Deprecated: main(): The Mongo class is deprecated, please use the MongoClient class in D:\bzyweb\test2\conn.php on line 11
Call Stack
# Time Memory Function Location
1 0.0010 238592 {main}( ) ..\conn.php:0
( ! ) Fatal error: Uncaught exception 'MongoConnectionException' with message 'Failed to connect to: localhost:27017: Authentication failed on database 'local' with username 'admin': auth fails' in D:\bzyweb\test2\conn.php on line 11
( ! ) MongoConnectionException: Failed to connect to: localhost:27017: Authentication failed on database 'local' with username 'admin': auth fails in D:\bzyweb\test2\conn.php on line 11
Call Stack
# Time Memory Function Location
1 0.0010 238592 {main}( ) ..\conn.php:0
2 0.0010 239720 __construct ( ) ..\conn.php:11
回複討論(解決方案)
Deprecated: main(): The Mongo class is deprecated, please use the MongoClient class
反對:main():Mongo類是過時的,請使用mongoclient類
echo "mongo contact:
";
//$DB = new PDO("mongodb:host=localhost;port=27017;dbname=aaa","admin","admin");
$conn = new MongoClient("mongodb://admin:admin@localhost2:27017/local");
?>
錯誤提示
mongo contact:
( ! ) Fatal error: Uncaught exception 'MongoConnectionException' with message 'MongoClient::__construct(): ' in D:\bzyweb\test2\conn.php on line 4
( ! ) MongoConnectionException: MongoClient::__construct(): in D:\bzyweb\test2\conn.php on line 4
Call Stack
# Time Memory Function Location
1 0.0000 240416 {main}( ) ..\conn.php:0
2 0.0000 240672 __construct ( ) ..\conn.php:4
你的是什嗎?mongo 管理器?
你看看他是怎麼寫的
是一個mongoweb的管理地址,我看了好多寫法,好像連結都是那麼寫的,不清楚為什麼我的出錯了,所以貼出來資料庫的結構,我想這樣能表述的更清晰一點
$dsn="mongodb://localhost:27017/admin:admin/aaa";
$m=new MongoClient($dsn);
沒有報錯了