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

What to do if php cannot connect to mysql under linux

王林
Release: 2023-03-04 20:52:02
Original
2873 people have browsed it

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
Copy after login

(Learning video recommendation: php video tutorial)

Then execute the following command to restart the apache2 server.

service apache2 restart
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template