Thinkphp database connection solution

Source: Internet
Author: User
I downloaded a thinkphp2.2 code from the Internet to connect to the thinkphp database, and created an index by myself. php, and then generate the project file, which is smooth, but cannot connect to the database. my code is very simple, & nbsp; $ modelnewModel (); & nbsp; $ model-& gt; query (& quot; select * fromthi thinkphp database connection
I downloaded a thinkphp2.2 code from the Internet, created an index. php, and generated the project file.
But I can't connect to the database. my code is very simple,
$ Model = new Model ();
$ Model-> query ("select * from think_person ;");
Conf/config. php file
Return array (
// 'Config maps '=> 'configuration value'
'Db _ type' => 'mysql', // Database TYPE
'Db _ host' => 'localhost', // server address
'Db _ name' => 'My _ table', // database NAME
'Db _ user' => 'root', // USER name
'Db _ pwd' => 'guozhixin ', // password
'Db _ port' => '123', // PORT
'Db _ prefix' => 'think _ ', // database table PREFIX
'Db _ SUFFIX '=> '', // database table SUFFIX
'Db _ FIELDTYPE_CHECK '=> false, // whether to check the field type
'Db _ FIELDS_CACHE '=> true, // enable field caching
'Db _ charset' => 'utf8', // The database encoding uses utf8 by default.
'Db _ DEPLOY_TYPE '=> 0, // Database deployment method: 0 centralized (single server), 1 distributed (master/slave server)
'Db _ RW_SEPARATE '=> false, // whether the master-slave mode is valid for database read/write splitting
);

The information is completely correct. I really don't know what's going on.


------ Solution --------------------
Your conf/config. php file contains
'Db _ pwd' => 'guozhixin ', // password

The error message is
Access denied for user 'root' @ 'localhost' (using password: NO)

Apparently, config. php is not loaded, or the path is incorrect.
Please delete all content in Runtime and try again

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.