Error 1044: Access denied for user ‘syz-remote’@‘%’ to database ‘webapp’
Cause: I was testing the code of golang
connecting to the database. I finally reinstalled MySQL
and set up remote login, but this problem still occurred.
My SYZ-remote
account is specially created for remote login. Therefore, unlike the root
user, it does not have the due permission. We need to set its permissions in MySQL
.
View MySQL
account permissions through this code
mysql> SELECT host,user,password_expired,Grant_priv,Super_priv FROM mysql.user;
+-----------+------------------+------------------+------------+------------+
| host | user | password_expired | Grant_priv | Super_priv |
+-----------+------------------+------------------+------------+------------+
| localhost | root | N | Y | Y |
| localhost | mysql.session | N | N | Y |
| localhost | mysql.sys | N | N | N |
| localhost | debian-sys-maint | N | Y | Y |
| % | syz-remote | N | N | N |
+-----------+------------------+------------------+------------+------------+
5 rows in set (0.00 sec)
You can see that the permission of Grant_priv and Super_priv
in syz-remote
is N
We gave him authority
update mysql.user set grant_priv = 'Y', Super_priv='Y' where user = 'syz-remote';
Refresh it again
flush privilegs;