Php links to the mongo database

Source: Internet
Author: User
Tags mongoclient
Php link mongo database $ conn = new Mongo ("mongodb: // admin: admin @ localhost: 27017/local"); // This is row 11th

An error is reported after this writing.

(! ) Deprecated: main (): The Mongo class is deprecated, please use the same client 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 'mongoonexception' with message 'failed' to connect to: localhost: 27017: Authentication Failed on database 'local' with username 'admin': auth fail' in D: \ bzyweb \ test2 \ conn. php on line 11
(! ) Failed connectionexception: 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


Reply to discussion (solution)

Deprecated: main (): The Mongo class is deprecated, please use the specified client class
Objection: the main (): Mongo class is outdated. use the 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 message
Mongo contact:

(! ) Fatal error: Uncaught exception 'Your ononexception' with message 'Your client ::__ construct (): 'In D: \ bzyweb \ test2 \ conn. php on line 4
(! ) Lost connectionexception: Lost client ::__ 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 is yours? Mongo manager?
Let's see how he wrote it.

It is a web management address of tranquility. I have read a lot of statements, as if the links are all written in that way. I don't know why I 've made a mistake, so I posted the database structure, I want to make it clearer.

$ Dsn = "mongodb: // localhost: 27017/admin: admin/aaa ";
$ M = new Alibaba client ($ dsn );
No error reported

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.