Changing user auth plugin in MySQL to 'sha256_password':
ALTER USER 'user'@'N.N.N.N' IDENTIFIED WITH 'sha256_password' BY 'password';
test.php
:
#!/usr/bin/env php
<?php
$my = new mysqli('M.M.M.M', 'user', 'password');
echo "OK\n";
$my->close();
?>
Doesn't work with 'sha256_password':
php test.php
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'user'@'hostname' (using password: YES) in /home/user/test.php on line 3
Changing user auth plugin back to 'mysql_native_password':
ALTER USER 'user'@'N.N.N.N' IDENTIFIED WITH 'mysql_native_password' BY 'password';
After changing auth plugin back to 'mysql_native_password' connection works:
php test.php
OK
Software versions:
php --version
PHP 7.2.25-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Nov 28 2019 07:41:59) ( NTS )
dpkg -l | grep libmysqlclient20
ii libmysqlclient20:amd64 5.7.28-0ubuntu0.16.04.2
mysqld -V
mysqld Ver 5.7.26-29-57 for debian-linux-gnu on x86_64 (Percona XtraDB Cluster (GPL), Release rel29, Revision 03540a3, WSREP version 31.37, wsrep_31.37)
Any ideas how to fix this?
UPDATE :
I also checked that it works with python MySQLdb connector:
import MySQLdb
con = MySQLdb.connect(host='127.0.0.1',user='user', passwd='password')
cur = con.cursor()
cur.execute('select 1')
print(cur.fetchall())
con.close()