PDO connection MySQL Error solution

Source: Internet
Author: User
Tags dsn odbc connection phpinfo
PDO connection MySQL Error

$dbms = ' MySQL ';
$dbName = ' Db_mrbook ';
$user = ' root ';
$pwd = ' 111 ';
$host = ' localhost ';
$DSN = "$dbms: host = $host;d bname = $dbName";
try{
$pdo = new PDO ($DSN, $user, $pwd);
echo "PDO link database succeeded";
}catch (Exception $e) {
echo $e->getmessage (). "
";
}
?>
Run-time display could not find driver
Modified extensions in Php.ini.dist and php.ini.recommended, removing Extension=php_mysql.dll, Extension=php_pdo.dll, and Extension=php_pdo_ Mysql.dll in front of the semicolon, restart Apache, or the same error, please greatly help

------Solution--------------------
Phpinfo () see if the load succeeds
------Solution--------------------
Take a look at the load configure file in Phpinfo () and see if the php.ini files are loaded.
------Solution--------------------
That's it.
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 Pooli NG  enabled, strict matching  pdo_sqlitepdo Driver for SQLite 3.x Enabled SQLite Library  3.7.4
------Solution--------------------
Whether you changed the php.ini is the Loaded Configuration File corresponding to the php.ini
  • 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.