MySQL-Access denied for user 'username'@'localhost' (using password: YES) 解决

Posted king西阳

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL-Access denied for user 'username'@'localhost' (using password: YES) 解决相关的知识,希望对你有一定的参考价值。

使用navicat新建mysql用户保存时提示 Access denied for user \'username\'@\'localhost\' (using password: YES):

解决方法:

请使用root账户登录mysql,执行下面命令行:

    1. MySQL 创建一个新用户,用户名为username,密码为password,将localhost改为%可允许该用户登录所有主机
      CREATE USER \'username\'@\'localhost\' IDENTIFIED BY \'password\';
    2. 为该用户授权,本例将所有权限全部授予给该用户,可以将ALL PRIVILEGES改为具体的权限选项,
      *.*代表所有数据库下的所有数据表,也可以指定为具体的数据库表
      GRANT ALL PRIVILEGES ON *.* TO \'username\'@\'localhost\' WITH GRANT OPTION
    3. 授权生效

      FLUSH PRIVILEGES;

重新登录即可。

以上是关于MySQL-Access denied for user 'username'@'localhost' (using password: YES) 解决的主要内容,如果未能解决你的问题,请参考以下文章

java访问数据库被拒绝,不能连接数据库ERROR 1045 (28000): Access denied for user 'root'@'localhost' (u

mysql报错 1142 - SELECT command denied to user 'root_ssm'@'localhost' for table 'u

CentOS-Mysql-Access denied for user root 更换root 密码

ERROR 1045 (28000): Access denied for user 'root'@'localhost'

mysql错误 Access denied for user 'root'@'xxx.xxx.xxx.xxx' (using password: YES)

Mysql denied for user 'odbc@localhost' || denied for user 'root@localhost'