How to check if user password is set in mysql?

authentication, mysql

Solution

MySQL versions 5.7 or higher doesnt have a column named password in mysql.user table. MySQL versions 5.7 or higher use the column authentication_string instead.

So you query should be:

SELECT host, user, authentication_string FROM mysql.user

Problem

I need to run automated checks against new servers. One of those checks is to detect if user (or `root`) password is set or not. But.. ``` mysql> SELECT host, user, password FROM mysql.user; ERROR 1054 (42S22): Unknown column 'password' in 'field list' ``` Server version: 5.7.18-0ubuntu0.17.04.1 (Ubuntu)

Original source