Solve the problem of nginx collusion with MySQL

Source: Internet
Author: User
Tags mysql host

Nginx and MySQL "collusion" more common error is, when the server's MySQL host default is localhost, nginx often can not find its database, even if the account password is not found, so that the database content can not be presented in the form of Web pages.


Is this the case?


This is mainly because under Linux, thenginx default link to MySQL is not the TCP protocol, but the socket, but when we open the relevant MySQL files, we will see MySQL to the socket file point to No_value,

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7F/CC/wKioL1ctlxHAWv6iAAEK2zl0j0c667.png "title=" 1.png " alt= "Wkiol1ctlxhawv6iaaek2zl0j0c667.png"/>


Come to the/var/lib/mysql/folder and you will see there is a mysql.sock, which is a pink file.


Then go back to the PHP installation folder, open folder under the lib/php will see php.ini, if not this file, return to the original PHP uncompressed download package, find php.ini-development, put this file CP to lib/ PHP in that folder.


Open Php.ini-development, find Mysql-socket is also empty,

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/7F/CE/wKiom1ctmZvh8f2IAAA1rGguMKA798.png "title=" 1.png " alt= "Wkiom1ctmzvh8f2iaaa1rggumka798.png"/>

Then fill in the full path of the pink file Mysql.sock to the back of the Mysql.default_socket. Then save exit, restart PHP-FPM, this time re-refresh the nginx MySQL bound database page, you should be able to see the database was successfully refreshed (at least a test default database).


Of course, if you do not like the socket communication, you can change the database host localhost to 127.0.0.1, forcing Nginx to go TCP protocol is also possible, so there is no need for so many things.


This article is from "Life is waiting for Gordo" blog, please make sure to keep this source http://chenx1242.blog.51cto.com/10430133/1771018

Solve the problem of nginx collusion with MySQL

Related Article

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.