PDO connection to MySQL error solution

Source: Internet
Author: User
Tags odbc connection
An error occurred while connecting to MySQL with PDO & lt ;? Php & nbsp; $ dbms = 'mysql'; & nbsp; $ dbName = 'DB _ mrbook'; & nbsp; $ user = 'root'; & nbsp; $ pwd = '000000'; & nbs PDO connection to MySQL error

$ Dbms = 'mysql ';
$ DbName = 'DB _ mrbook ';
$ User = 'root ';
$ Pwd = '000000 ';
$ Host = 'localhost ';
$ Dsn = "$ dbms: host = $ host; dbname = $ dbName ";
Try {
$ Pdo = new PDO ($ dsn, $ user, $ pwd );
Echo "PDO connected to the database succeeded ";
} Catch (Exception $ e ){
Echo $ e-> getMessage ()."
Show cocould not find driver at runtime
Modified php. ini. dist and php. ini. extension = php_mysql.dll, extension = php_pdo.dll and extension = php_pdo_mysql.dll are removed from the extension in recommended. If Apache is restarted, the same error occurs. please help me a lot.

------ Solution --------------------
Phpinfo () to check whether the load is successful
------ Solution --------------------
Check the load configure file in phpinfo () to see which php. ini file is loaded.
------ Solution --------------------
In this way, you can
PHP code
PDOPDO support enabled PDO drivers mysql, odbc, sqlite pdo_mysqlPDO Driver for MySQL enabled Client API version mysqlnd 5.0.8-dev-20102224-$ Revision: 308673 $ PDO_ODBCPDO Driver for ODBC (Win32) enabled ODBC Connection Pooling Enabled, strict matching pdo_sqlitePDO Driver for SQLite 3.x enabled SQLite Library 3.7.4
------ Solution --------------------
Whether the php. ini you changed is the php. ini corresponding to the Loaded Configuration File
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.