问题现象:
mysql> show databases;
ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
解决方法:
1.先看下mysql是否设置了环境变量,如果没设置,就需要切换到mysql的bin目录下执行命令
mysql -P 3306 -h 127.0.0.1 -u root -p
2.给root用户添加权限
mysql8.0以前的版本可以使用grant在授权的时候隐式的创建用户,8.0以后已经不支持,所以必须先创建用户,然后再授权,命令如下:
CREATE USER 'mysql.infoschema'@'localhost' IDENTIFIED BY '123456';
grant all privileges on *.* to 'mysql.infoschema'@'localhost';
flush privileges;
如果远程连接的时候报plugin caching_sha2_password could not be loaded这个错误,可以尝试修改密码加密插件:
alter user 'root'@'%' identified with mysql_native_password by '123456';