$dsn = " mysql:host = localhost;dbname = pdotext " ; 上面就是错误的代码 在dbname 等号后面不能写空格 不然会找不到数据库 这个是正确的 $dsn = " mysql:host=localhost;dbname=pdotext " ;