MySQL список неактивных учетных записей и схем

SELECT DISTINCT
    mu.user, 	mu.host
FROM
    mysql.user mu
        LEFT JOIN
    performance_schema.accounts psa ON mu.user = psa.user
        AND psa.host LIKE mu.host
        LEFT JOIN
    information_schema.views isv ON isv.security_type = 'definer'
        AND isv.definer LIKE CONCAT(mu.user, '@', mu.host)
        LEFT JOIN
    information_schema.routines isr ON isr.security_type = 'definer'
        AND isr.definer LIKE CONCAT(mu.user, '@', mu.host)
        LEFT JOIN
    information_schema.events ise ON ise.definer LIKE CONCAT(mu.user, '@', mu.host)
        LEFT JOIN
    information_schema.triggers ist ON ist.definer LIKE CONCAT(mu.user, '@', mu.host)
WHERE
    psa.user IS NULL AND isv.definer IS NULL
        AND isr.definer IS NULL
        AND ise.definer IS NULL
        AND ist.definer IS NULL
ORDER BY mu.user, mu.host;

Пример вывода

Close Menu