MySQL权限问题

前言

连接mysql报错java.sql.SQLException: Access denied for user ‘root’@’IP一直会报错,尝试了修改host,还是有问题。

#给单个IP用户授权

1
2
# 给一个用用户use ip: 1.1.1.1
grant all on *.* to root@11.1.1.1 identified by 'passwd'

授权连接全部的ip地址

1
2
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' identified by 'mima' WITH GRANT OPTION;
FLUSH PRIVILEGES