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.
When I submit a job with qsub to SGE, the job's shell will not read .bashrc. Is there a file analogous to .bashrc that will be read by the shell of all jobs started with qsub?
I know there is a .sge_request file, but it only contains default options for qsub, not a list of commands like .bashrc. What I want is to set some environment variables for my job, like $PATH and $LD_LIBRARY_PATH. I don't think I can do that with .sge_request, but if I can, that would also solve my problem.
This is better accomplished using the -V option to qsub , which imports all environment variables set, including those in .bashrc.
.bashrc can be read if you submit an interactive job, just change the header of your job script to:
#!/bin/bash -i
I'd like to automatically populate Memory tables each time the MySQL Server reboots. Is there a way I can set a trigger which is based on that event? Or a script which is run by either the Mysqd or mysqld_safe startup scripts?
Thanks in advance
You can use the below startup script for linux :
add the followin in init.d file.
vi /etc/init.d/ you have to set it executable with: chmod +x /etc/init.d/start_my_app And dont forget to add #!/bin/sh on top of that file
And put the complete location of your script in it, like /var/myscripts/test.php instead of just start_my_app
in test.php page you can have mysql query executed.
You can set a command line option "--init-file=file_name" whenever mysql start
--init-file=file_name
Command-Line Format --init-file=file_name
Option-File Format init-file
Read SQL statements from this file at startup. Each statement must be on a single line and should not include comments.
This option is unavailable if MySQL was configured with the --disable-grant-options option.
Source : Mysql developer Documentation
For More Detail
http://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_init-file
Attempting to use ${HOSTNAME} in a config file does not work! According to the documentation, config files should resolve environment variables as mentioned in the docs:
substitutions fall back to environment variables if they don't resolve in the config itself, so ${HOME} would work as you expect. Also, most configs have system properties merged in so you could use ${user.home}.
Is there a way to get hostname into the config file?
Reproduction
Add host.name=${HOSTNAME} to an application.conf file, then try and access it from anywhere. For example try adding
Logger.info(s"Hostname is ${current.configuration.getString("host.name").getOrElse("NOT-FOUND")}")
to the Global.scala.
Environment
This was run on a RHEL6 environment where echo $HOSTNAME produces precise32 so the environment variable exists, this is not the program hostname.
The solution seems to be passing in the hostname via a system property as -Dhost.name=$HOSTNAME or -Dhost.name=$(hostname). I'd imagine in windows it would be something else, but this works for *NIX environments.
Unless anyone can come up with something cleaner this will be the accepted answer.
This probably isn't working because $HOSTNAME doesn't seem to actually be an environment variable:
jamesw#T430s:~$ echo $HOSTNAME
T430s
jamesw#T430s:~$ export|grep HOSTNAME
jamesw#T430s:~$
So it must be some other special bash thing.
You should see if calling System.getenv("HOSTNAME") returns a non-null value. If not, then HOSTNAME is not an env variable according to the java runtime which is what is important for mapping that to a config property in typesafe config. I tried this with HOSTNAME and even though I could echo it in bash, it was not available in java as a env substitution. I changed it to USER and everything worked as expected.
Is it possible to read env vars in MySQL option file my.ini/my.cnf, the way it is possible in httpd.conf and php.ini with the ${ENVVAR} syntax :
datadir="${MYSQL_DATA_HOME}/Data/"
If yes, what is the syntax ?
I think it is not possible. I tried making the same changes in MySQL option file, but failed to start. But there is another way though.
Set MYSQL_DATA_HOME=<some dir> in the console. And in the same terminal start mysql not by service start but with this command mysqld --datadir=$MYSQL_DATA_HOME/whatever