Fabien Snauwaert Fabien Snauwaert -4 years ago 69
MySQL Question

How to trigger an error in mysqld

I'm setting up a development environment.

I'd like to check whether logging works as expected for MySQL.

How can I do so programmatically from PHP?

Inspired by this answer, I merely ran a minimal test like this:

<?php

$pdo = new \PDO(
'mysql:host=localhost;',
'root',
''
);
$result = $pdo->query( "signal sqlstate '45000' set message_text = 'Triggering error on purpose (test)';" );

?>


However, this does not trigger any error in the error log. I'd expect the error in
/var/log/mysql/
(in
error.log
.)

I'm running Ubuntu 16.04 inside of Docker on OS X and using MariaDB.

This is a question at the crossroad between programming and sysadmin, so feel free to migrate it to AskUbuntu if you think it's more relevant there.

Answer Source

The mysql error.log does not receive errors meant for the calling program.

Se the error.log documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download