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


    配置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用户登陆,输入密码成功。

  • 相关阅读:
    用vuex写了一个购物车H5页面的示例代码
    css如何引入外部字体?
    移动开发中更好的图片自适应
    常见样式问题七、word-break、word-wrap、white-space区别
    你真的了解word-wrap和word-break的区别吗?
    css中word-break、word-wrap和white-space的区别
    另辟蹊径:vue单页面,多路由,前进刷新,后退不刷新
    应该用forEach改变数组的值吗? 原生JS forEach()和map()遍历的异同点
    Vue 全家桶介绍
    Spring MVC配置MyBatis输出SQL
  • 原文地址:https://www.cnblogs.com/lingluo2017/p/8719713.html
Copyright © 2020-2023  润新知