PHP Link MONGO Database

Source: Internet
Author: User
Tags dsn mongoclient
$conn = new Mongo ("mongodb://admin:admin@localhost:27017/local"); This is line 11th.

After writing this, the error

( ! ) 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:authentica tion 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 in 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


Reply to discussion (solution)

Deprecated:main (): The Mongo class is Deprecated, please use the Mongoclient class
Objection: Main (): MONGO class is obsolete, please use mongoclient class

echo "MONGO Contact:
";
$DB = new PDO ("Mongodb:host=localhost;port=27017;dbname=aaa", "admin", "admin");
$conn = new Mongoclient ("mongodb://admin:admin@localhost2:27017/local");
?>

Error hints
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

What's yours? MONGO Manager?
You see how he wrote it.

is a mongoweb management address, I read a lot of writing, as if the link is so written, do not know why I made a mistake, so put out the structure of the database, I think this can be expressed more clearly

$DSN = "MONGODB://LOCALHOST:27017/ADMIN:ADMIN/AAA";
$m =new mongoclient ($DSN);
There's no error.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.