sexta-feira, 18 de julho de 2014

Erro MySQL secure_auth

Original post: http://anothermysqldba.blogspot.com/2014/07/mysql-secureauth-error.html

Eu abordou os erros secure_auth antes, quando ele bloqueia a replicação neste post do blog . 

No entanto, eu percebi que eu iria fazer neste blog postar uma correção mais geral ao conectar via clientes MySQL. Isto é para os servidores antes do MySQL 5.6. 

Portanto, se você receber um erro secure_auth quando a conexão ao MySQL os seguintes passos devem resolver este erro. 

+---------------+-------------------------------------------+ 
| User | Password | 
+---------------+-------------------------------------------+ 
| authdtestuser | 34d22ac342c35af2
 +---------------+-------------------------------------------+ 
| User | Password | 
+---------------+-------------------------------------------+ 
| authdtestuser | 34d22ac342c35af2 | |+---------------+-------------------------------------------+ 

SELECT @@session.old_passwords, @@global.old_passwords; +-------------------------+------------------------+ 
| @@session.old_passwords | @@global.old_passwords | 
+-------------------------+------------------------+ 
| 1 | 1 | 
+-------------------------+------------------------+ 

mysql> SET @@session.old_passwords = 0; SET @@global.old_passwords=0; 
Query OK, 0 rows affected (0.00 sec) 

mysql> SELECT @@session.old_passwords, @@global.old_passwords; 
+-------------------------+------------------------+ 
| @@session.old_passwords | @@global.old_passwords | 
+-------------------------+------------------------+ 
| 0 | 0 | 
+-------------------------+------------------------+ 
1 row in set (0.00 sec) 

mysql> SET PASSWORD FOR 'authdtestuser'@'localhost' = PASSWORD('sshthisisasecret'); 
Query OK, 0 rows affected (0.00 sec) 

mysql> select User , Password from mysql.user where User = 'authdtestuser'; 
+---------------+-------------------------------------------+ 
| User | Password | 
+---------------+-------------------------------------------+ 
| authdtestuser | *E48BD8BF1B9F29459E5284AD158443B5B33B70E4 | 
+---------------+-------------------------------------------+ 
1 row in set (0.00 sec) 

mysql> SET @@session.old_passwords = 1; SET @@global.old_passwords=1; 

mysql> SELECT @@session.old_passwords, @@global.old_passwords; 
+-------------------------+------------------------+ 
| @@session.old_passwords | @@global.old_passwords | 
+-------------------------+------------------------+ 
| 1 | 1 | 
+-------------------------+------------------------+ 
1 row in set (0.00 sec) 
| |+---------------+-------------------------------------------+ 

SELECT @@session.old_passwords, @@global.old_passwords; +-------------------------+------------------------+ 
| @@session.old_passwords | @@global.old_passwords | 
+-------------------------+------------------------+ 
| 1 | 1 | 
+-------------------------+------------------------+ 

mysql> SET @@session.old_passwords = 0; SET @@global.old_passwords=0; 
Query OK, 0 rows affected (0.00 sec) 

mysql> SELECT @@session.old_passwords, @@global.old_passwords; 
+-------------------------+------------------------+ 
| @@session.old_passwords | @@global.old_passwords | 
+-------------------------+------------------------+ 
| 0 | 0 | 
+-------------------------+------------------------+ 
1 row in set (0.00 sec) 

mysql> SET PASSWORD FOR 'authdtestuser'@'localhost' = PASSWORD('sshthisisasecret'); 
Query OK, 0 rows affected (0.00 sec) 

mysql> select User , Password from mysql.user where User = 'authdtestuser'; 
+---------------+-------------------------------------------+ 
| User | Password | 
+---------------+-------------------------------------------+ 
| authdtestuser | *E48BD8BF1B9F29459E5284AD158443B5B33B70E4 | 
+---------------+-------------------------------------------+ 
1 row in set (0.00 sec) 

mysql> SET @@session.old_passwords = 1; SET @@global.old_passwords=1; 

mysql> SELECT @@session.old_passwords, @@global.old_passwords; 
+-------------------------+------------------------+ 
| @@session.old_passwords | @@global.old_passwords | 
+-------------------------+------------------------+ 
| 1 | 1 | 
+-------------------------+------------------------+ 
1 row in set (0.00 sec)