First locate the config.php file under the Conf subdirectory in the common directory in the project files directory
Add the following code:
' Db_type ' = ' PDO ',
' Db_user ' = ' root ',
' Db_pwd ' = ' database password ',
' Db_prefix ' = ' think_ ', table prefix
' Db_dsn ' = ' mysql:host=localhost;dbname= connected database name; Charset=utf8 '
Note: Charset=utf8 instead of UTF-8, write UTF-8 page will error.
There is one more way: for instantiating with model () models, you can:
Model ([' model name '],[' data table prefix '],[' database connection information '); The third parameter defines a database in the database connection information
such as: $user = new Model (' User ', ' think_ ', ' mysql://root:123456@localhost/thinkphp ');
The database connection Information format is: Database type://user name: password @ Database address: Database port/Database name # Character Set
This example corresponds to the actual change