Home > Article > Backend Development > Beginner's question: PDO operations on linux
I just applied for a student machine recently. I tried to connect to the database on Linux:
<code>try { $conn = new PDO("mysql:host=$server;dbname=$db",$user,$pass); echo "connection success!"; } catch(PDOException $e) { echo $e->getMessage(); }</code>
However, the webpage cannot be connected, and the status code returned is: 500
The local host test connection is successful, and the confirmation code is correct (the account number, password, and database are all correct),
Under linux host, test:
php test.php //Return connection success!
It’s strange, why can the php command be run but the webpage just can’t be displayed?
Is it because there is no PDO extension? If yes, then how do I install it?
I just applied for a student machine recently. I tried to connect to the database on Linux:
<code>try { $conn = new PDO("mysql:host=$server;dbname=$db",$user,$pass); echo "connection success!"; } catch(PDOException $e) { echo $e->getMessage(); }</code>
However, the webpage cannot be connected, and the status code returned is: 500
The local host test connection is successful, and the confirmation code is correct (the account number, password, and database are all correct),
Under linux host, test:
php test.php //Return connection success!
It’s strange, why can the php command be run but the webpage just can’t be displayed?
Is it because there is no PDO extension? If yes, then how do I install it?
Mostly the mysql user permissions are set incorrectly, local access is available, but Yuncheng denies access
$server
If it is "localhost"
, why not try changing it to "127.0.0.1"
? The two are different.