1.问题来源
照着书上的案例敲以下案例发现报语法错误。
SET PASSWORD FOR user_name@ip_address = PASSWORD('password_value');
# result:
# 1064 - 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 '% = PASSWORD('p@$$word')' at line 1
2.错误原因:
mysql8.0版本不支持使用set password命令。
3.解决办法
# 方法1
ALTER USER 'user_name'@'ip_address' IDENTIFIED by 'password_value';
# 方法二
ALTER USER 'user_name'@'ip_address' IDENTIFIED
WITH mysql_native_password BY 'new_password_value';