Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How php connects to mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Today, I will talk to you about how PHP connects MySQL. Many people may not know much about it. In order to let everyone know more, Xiaobian summarizes the following contents for everyone. I hope you can gain something according to this article.

Install the server and script processing naturally or install a database, in https://dev.mysql.com/downloads/mysql/download the latest version of windows (this time is 8.0.17), download the same in the Web directory to create Mysql directory, extract the files into it

Then go to the bin directory, open cmd as administrator, and type

mysqld --initialize

used to initialize the data, and then enter

mysqld install

To install mysql services, type

net start mysql

To start mysql services, when you see

The MySQL service is starting.The MySQL service was started successfully.

It means success. You can find the current username.err under the data folder. Open it and you can see the generated root account and random password.

However, mysql must change the initial password because of security policy. Enter

mysql -u root -p

Log in, enter the generated random password to log in, log in successfully and enter

alter user 'root'@'localhost'IDENTIFIED BY 'new password';

All right, everything uses the default settings on the line, you need to set the global individual can create my.ini in the Mysql folder, the content of their own search

One thing to note,mysql uses a new authentication method caching_sha2_password , but it seems that php pdo does not seem to support, to use mysql8 will use a compromise approach, mysql authentication method changed to the original mysql_native_password

So log in to mysql from the command line and type

alter user 'root'@'localhost'IDENTIFIED with mysql_native_password BY 'new password';

PHP can connect to MySQL.

After reading the above, do you have any further understanding of how PHP connects to MySQL? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report