In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the php mysql connection is not on the solution, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.
Php mysql connection solutions: 1, establish a PHP file to display "phpinfo ()"; 2, get the MySQL socket path; 3, reconfigure PHP;4, restart nginx or apache.
This article operating environment: Windows7 system, PHP5.5.34 version, DELL G3 computer
Summary of MySQL solutions that cannot be connected to PHP
1. Get the current mysql.default_socket, mysqli.default_socket, and pdo_mysql.default_socket configuration information
Create a PHP file that displays phpinfo ():
Open it with a browser:
On this page, find mysql.default_socket, mysqli.default_socket, pdo_mysql.default_socket information:
two。 Get MySQL socket path
Enter MySQL through the console and enter the command: STATUS to find the UNIX socket value
# mysql-u root-pEnter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 8Server version: 5.7.11 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > STATUS-mysql Ver 14.14 Distrib 5.7.11, for osx10.9 (x86 / 64) using EditLine wrapperConnection id: 8Current database: Current user: root@localhostSSL: Not in useCurrent pager: lessUsing outfile:''Using delimiter: Server version: 5.7.11 MySQL Community Server (GPL) Protocol version: 10Connection: Localhost via UNIX socketServer characterset: utf8Db characterset: utf8Client characterset: utf8Conn. Characterset: utf8UNIX socket: / tmp/mysql.sockUptime: 8 days 15 hours 1 min 17 secThreads: 2 Questions: 21 Slow queries: 0 Opens: 114 Flush tables: 1 Open tables: 0 Queries per second avg: 0.000-
3. At this point, you can see the difference between mysql.default_socket, mysqli.default_socket, pdo_mysql.default_socket and MySQL UNIX socket, which is mysql_connect (); the reason for the warning: there is a problem with PHP configuring mysql.
4. Reconfigure PHP and open php.ini to modify the values of mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket: / tmp/mysql.sock
Pdo_mysql.default_socket=/tmp/mysql.sock mysql.default_socket=/tmp/mysql.sock mysqli.default_socket=/tmp/mysql.sock
Or modify the socket of my.cnf:
[client] socket=/tmp/mysql.sock [mysqld] socket=/tmp/mysql.sock
5. Restart nginx or apache
Thank you for reading this article carefully. I hope the article "the solution to the disconnection of mysql in php" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.