Home  >  Article  >  Backend Development  >  What to do if php cannot connect to mysql under linux

What to do if php cannot connect to mysql under linux

王林
王林Original
2020-08-20 13:21:302833browse

Solution to the problem that php cannot connect to mysql under Linux: First open the terminal; then execute the [apt install php-mysql] command to install the php-mysql module; finally execute the [service apache2 restart] command to restart the server.

What to do if php cannot connect to mysql under linux

Cause analysis:

It may be that the php-mysql module is not installed.

(Recommended tutorial: php graphic tutorial)

Solution:

First execute the following command to install the module:

apt install php-mysql

(Learning video recommendation: php video tutorial)

Then execute the following command to restart the apache2 server.

service apache2 restart

The above is the detailed content of What to do if php cannot connect to mysql under linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn