今天学习过程中遇到一个问题,我的MySQL版本为8.0.16 ,在创建新用户并给新用户添加数据库权限时使用命令:
grant all on vsearchlogdb.* to 'vsearch' identified by 'vsearchpasswd';
遇到以下的报错:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'vsearchpasswd'' at line 1,错误指出在 'identified by 'vsearchpasswd''出现解析错误,后来尝试将创建用户和添加权限分开:
#创建vsearch用户及口令‘vsearchpasswd’
create user 'vsearch'@'local' identified by 'vearchpassword';
#给用户vsearch'添加数据库'vsearchlogdb'的所有权限
grant all privileges on vsearchlogdb.* to 'vsearch'@'localhost';
再次运行,ok