PHP Fatal error: Class 'PDO' not found in /home/bd/public_html/app/webroot/Cake/Model/Datasource/Database/Mysql.php on line 177
PHP INFO:
PDO
PDO support => enabled
PDO drivers => sqlite, sqlite2, mysql
pdo_mysql
PDO Driver for MySQL => enabled
Client API version => 5.5.24
Directive => Local Value => Master Value
pdo_mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
pdo_sqlite
PDO Driver for SQLite 3.x => enabled
SQLite Library => 3.7.7.1
PHP INI:
extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so
CODE:
/**
* Check whether the MySQL extension is installed/loaded
*
* #return boolean
*/
public function enabled() {
return in_array('mysql', PDO::getAvailableDrivers());
}
Ideas as to why I'm getting this error?
PHP 5.3.15
CloudLinux/CentOS 6
CPanel
try
yum install php-pdo
yum install php-pdo_mysql
service httpd restart
Try adding use PDO; after your namespace or just before your class or at the top of your PHP file.
This can also happen if there is a php.ini file in the web app's current working directory. If one has been placed there to change certain settings, it will override the global one.
To avoid this problem, don't use a php.ini file to change settings; instead you can:
Specify settings in the vhost declaration
Use an .htaccess file with php_flag (see here)
Use an .user.ini file (see here)
Ensure they are being called in the php.ini file
If the PDO is displayed in the list of currently installed php modules, you will want to check the php.ini file in the relevant folder to ensure they are being called. Somewhere in the php.ini file you should see the following:
extension=pdo.so
extension=pdo_sqlite.so
extension=pdo_mysql.so
extension=sqlite.so
If they are not present, simply add the lines above to the bottom of the php.ini file and save it.
What is the full source of the file Mysql.php. Based on the output of the php info list, it sounds like you may be trying to reference a global class from within a namespace.
If the file Mysql.php has a statement "namespace " in it, use \PDO in place of PDO - this will tell PHP to look for a global class, rather than looking in the local namespace.
I had the same problem on GoDaddy. I added the extension=pdo.so to php.ini, still didn't work. And then only one thing came to my mind: Permissions
Before uploading the file, kill all PHP processes(cPanel->PHP Processes).
The problem was that with the file permissions, it was set to 0644 and was not executable . You need to set the file permission at least 0755.
you can just find-out loaded config file by executing below command,
php -i | grep 'php.ini'
Then add below lines to correct php.ini file
extension=pdo.so
extension=pdo_sqlite.so
extension=pdo_mysql.so
extension=sqlite.so
Then restart web server,
service httpd restart
Its a Little Late but I found the same problem and i fixed it by a "\" in front of PDO
public function enabled() {
return in_array('mysql', \PDO::getAvailableDrivers());
}
This error is caused by PDO not being available to PHP.
If you are getting the error on the command line, or not via the same interface your website uses for PHP, you are potentially invoking a different version of PHP, or utlising a different php.ini configuration file when checking phpinfo().
Ensure PDO is loaded, and the PDO drivers for your database are also loaded.
For Fedora 33 you can install as follows:
Install
dnf install php-pdo
dnf install php-pdo_mysql
Restart PHP
systemctl restart php-fpm.service
I solved it with library PHP_PDO , because my hosting provider didn't accept my requirement for installation of PDO driver to apache server.
If you run php with php-fpm module,do not forget to run command systemctl restart php-fpm!That will reload php-fpm module.
I had to run the following on AWS EC2 Linux instance (PHP Version 7.3):
sudo yum install php73-php-pdo php73-php-mysqlnd
After a long time, I finally solved it. check your folder in Cpanel to see if there is a php.ini file. if yes delete it since Cpanel will be using its own php.ini
If anyone getting this error in cPanel, please check the PHP version type in your cPanel. Change it, alt-php to ea-php. This setting worked for me.
Consider:
Now I am getting this error. How can I resolve this issue?
I found found some related issue, but that told me change max-size inside file php.ini, so how can I edit file php.ini (phpmyadmin-config)?
Importing into MySQL, the database size is above 100 MB. And the MySQL database size converts it into a ZIP file, and then import working, but it is not inserting all tables.
I'm not sure which OS or Apache server you're using right now.
If you are not aware of the php.ini file path then create one info.php file inside your www/htdocs folder and write the below line of code inside that file.
<?php echo phpinfo(); ?>
Execute the above file in your web browser. You will find the loaded php.ini configuration file path, like shown below.
Now go to the file path and increase the values of the below two variables as per your need.
upload_max_filesize=128M
post_max_size=128M
PS: Don't forget to restart your Apache server. :)
The configuration file is located at the below path:
/etc/php/php_version/apache2/php.ini
Now increase the value of:
post_max_size = 150MB
upload_max_size = 150MB
Then restart the server:
sudo service apache2 restart
I want to enable LDAP module on my XAMPP Windows 10, here's the few solutions that I've tried :
Copy dll files to System and System32 and uncomment extension=php_ldap.dll in php.ini, both development and production.
Copy libsasl.dll to xampp/apache/bin
None of these working, when I opened phpinfo() there is no ldap info showing, which means the ldap hasn't been able to installed. I also added PHP in Windows Path with no success, but either my approach is wrong or that wasn't a solution. Any help appreciated.
Make sure the path\to\xampp\php directory has the following files
libeay32.dll
libsasl.dll
ssleay32.dll
Usually, you can find these files in path\to\xampp\sendmail - this library also uses them. But if not, try to search for them inside the xampp directory.
Uncomment or add the ldap extension in the php.ini (path\to\xampp\php\php.ini) file
extension=ldap
Restart the server
Make sure the path\to\xampp\php directory is set in the system environment variable PATH. To know how to do it, see this post.
I just ran into the same issue and the link you provided How to enable LDAP extension in XAMPP environment ended up being the solution for me.
I copied libeay32.dll and ssleay32.dll from C:/Ampps/php to C:/Windows/System32. I made sure neither of these files were in C:/Windows/System. From there I enabled extension=php_ldap.dll in the php.ini file. Ampps has a list you can enable php.ini dll's and if I remember right so does XAMPP. The last step is to just restart Apache and you should be good to go.
I'm using Windows 10 with Ampps instead of XAMPP but have to think they are pretty close.
I am not able to start the MySQL server on my Windows system. When I tried in services.msc to run, I got this error:
Starting it through the XAMPP control panel does not work either:
Can you help me to solve this?
Open windows services (Start->run ->Services.MSC)
Find service with name "Mysql Server" and check path, it should be something like that:
"C:\Program Files (x86)\Parallels\Plesk\Databases\MySQL51\bin\mysqld.exe" "--defaults-file=C:\Program Files (x86)\Parallels\Plesk\Databases\MySQL\Data\my.ini" MySQL
Make sure that Mysql folder and executable file mentioned above exist by this path.
OR
Sometimes the file name of mysqld-nt.exe renamed to mysqld-nt.exe~ so rename it back to its original name and this may solve the problem.
Go to the path: C:Programs Files\MariaDB 10.2\data..
Lookout for my.ini file. Open the file and check the path for "datadir".
If that does not match to your installed directory then update it.
Your problem will be solved for sure.
I faced the same problem and solved it.
Just modify the registry editor value.
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/MySQL/ImagePath
When I try to start my SQL server, a message pops up saying that it starts but then stops. This happened after a restart on my server.
Does anyone know how I can fix this?
Make sure that the data directory has full permissions set for users "Network Service" and Administrator and that you have quotes around the name of the directory if there are spaces in it. Make sure that basedir is set / not commented out.
I tested these things by changing the data directory, which re-caused the error you describe above exactly, then fixed the permissions of the newly created data directory to eliminate the error. I can switch back and forth now my changing which data directory I comment out. (only as a test, otherwise that's kind of nuts).
C:\ProgramData\MySQL\MySQL Server 5.7\my.ini Should be something like this, using Windows 2012 R2 server to test:
# Path to installation directory. All paths are usually resolved relative to
this.
basedir="C:/Program Files/MySQL/MySQL Server 5.7/"
# Path to the database root
# datadir="C:/ProgramData/MySQL/MySQL Server 5.7/Data"
datadir="d:/ProgramData/Data"
Please try the following steps:
run 'cmd' as administrator,
cd to your SQL folder,
run 'mysqld --initialize --user=mysql --console' to reset and
run 'net start mysql' to start the service.
Nothing worked for me except for uninstalling the current 5.7.35 and then installing the 5.7.31. Try downgrading. Might help!
add to config file my.inf on C:\ProgramData\MySQL\MySQL Server 5.7
[mysqld]
tmpdir=C:/temp
and everything will work fine .