码迷,mamicode.com
首页 > 数据库 > 详细

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'ambari'

时间:2018-04-05 01:30:04      阅读:1730      评论:0      收藏:0      [点我收藏+]

标签:技术   图片   ant   inf   def   div   ali   com   body   

配置Ambari远程maridb 报错:

ERROR 1044 (42000): Access denied for user ‘‘@‘localhost‘ to database ‘ambari‘

在环境搭建的过程中,在

#Ambari用户(上面设置的用户)登录mysql (没有密码)

mysql -u ambari -p

use ambari

source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

遇到了:

ERROR 1044 (42000): Access denied for user ‘‘@‘localhost‘ to database ‘ambari‘

 

背景:因为之前安装过Mysql,又把mysql卸载了,然后又安装的mariadb

初步判断,可能是没有创建databases,或者密码错了,或者没有配置mariadb 远程连接的等配置信息(my.cnf)

 

按照思路逻辑,来验证第一个问题:

换成root用户,尝试登陆,查看是否有ambari database

[root@n1 ~]# mysql -uroot –proot

 

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| activity           |

| ambari             |

| amon               |

| cm                 |

| hive               |

| hueDEFAULT         |

| information_schema |

| mysql              |

| oozie              |

| oozieDEFAULT       |

| performance_schema |

| python             |

+--------------------+

如上述所示,是有ambari数据库的。

 

面对第二个问题,我的解决方案是:

mysql -uambari –p

直接敲回车,没有密码:

显示:

MariaDB [(none)]> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

+--------------------+

1 row in set (0.00 sec)

如上都不是解决问题的答案:

最终解决方案:花了1个小时48分钟,解决如上的BUG.

正确的思路:是权限问题。

root权限登陆mariadb

MariaDB [(none)]>  SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user;

+-----------+--------+-------------------------------------------+------------+------------+

| host      | user   | password                                  | Grant_priv | Super_priv |

+-----------+--------+-------------------------------------------+------------+------------+

| localhost | root   | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y          | Y          |

| 127.0.0.1 | root   | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y          | Y          |

| ::1       | root   | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y          | Y          |

| %         | ambari | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y          | Y          |

| %         | hive   | *6B992DD2D480F43212F044AB3ECAF17E1EA056B9 | N          | Y          |

| %         | oozie  | *2F2E0D3AD70093DDB3F8964E3984EA04B40A6D3C | N          | Y          |

+-----------+--------+-------------------------------------------+------------+------------+

6 rows in set (0.00 sec)

 技术分享图片

 

此时ambari用户的Grant_priv的权限为N(图上是Y是因为修改后的解决方案)

输入sql:

UPDATE mysql.user SET Grant_priv=‘Y‘, Super_priv=‘Y‘ WHERE User=‘ambari‘;

然后用ambari用户登陆,输入密码成功。

 

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'ambari'

标签:技术   图片   ant   inf   def   div   ali   com   body   

原文地址:https://www.cnblogs.com/lingluo2017/p/8719713.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!