Access denied for user ‘用户名‘@‘localhost‘ to database ‘数据库名‘

0.起因:直接导入sql脚本,生成数据库和表以及数据,第一句CREATE DATABASE IF NOT EXISTS 数据库名称;报标题的这个错误
1.原因:该用户没有创建数据库权限
2.解决:给用户赋权,赋予所有权限

grant all privileges on *.* to '用户名'@'localhost' identified by '密码' with grant option;

Access denied for user ‘用户名‘@‘localhost‘ to database ‘数据库名‘_第1张图片
Access denied for user ‘用户名‘@‘localhost‘ to database ‘数据库名‘_第2张图片

你可能感兴趣的:(数据库,mysql)