Fabien Snauwaert
Fabien Snauwaert

Reputation: 5661

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.

Upvotes: 0

Views: 45

Answers (1)

Mikpa
Mikpa

Reputation: 1932

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

Se the error.log documentation.

Upvotes: 1

Related Questions