1 打开php.ini配置文件,找到;extension=pdo_mysql,将前面的;去掉。

2 在php文件中连接使用数据库

<?php
//echo "Hello world";
$dsn = "mysql:host=localhost;dbname=db2019";
$db = new PDO($dsn, 'root', '12345678');
$rs = $db->query("select * from payment");
$result_arr = $rs->fetchAll();
print_r($result_arr);
$db = null;
?>
Array ( 
[0] => Array (
[id] => 1
[0] => 1
[serial] => test1
[1] => test1
)
[1] => Array (
[id] => 2
[0] => 2
[serial] => test2
[1] => test2
)
)