CDH 初始化数据库 报错ERROR Exception when creating/dropping database with user 'root' and jdbc url 'jdbc:mys

初始化报该错CDH 初始化数据库 报错ERROR Exception when creating/dropping database with user ‘root’ and jdbc url ‘jdbc:mysql://localhost/?useUnicode=true&characterEncoding=UTF-8’,原因是没有该用户,无法创建。

初始化命令格式:
CDH 初始化数据库 报错ERROR Exception when creating/dropping database with user 'root' and jdbc url 'jdbc:mys

解决方法:进到mysql数据库里添加创建用户,格式如下
grant all privileges on . to ‘root’@‘localhost’ identified by ‘123456’ with grant option;

grant all privileges on . to ‘root’@‘hadoop1’ identified by ‘123456’ with grant option;

grant all privileges on . to ‘root’@‘127.0.0.1’ identified by ‘123456’ with grant option;

grant all privileges on . to ‘root’@’%’ identified by ‘123456’ with grant option;

grant all privileges on . to ‘scm’@‘localhost’ identified by ‘scm’ with grant option;

grant all privileges on . to ‘scm’@‘hadoop1’ identified by ‘scm’ with grant option;

grant all privileges on . to ‘scm’@‘127.0.0.1’ identified by ‘scm’ with grant option;

grant all privileges on . to ‘scm’@’%’ identified by ‘scm’ with grant option;

PS。如果数据库里有cm和scm表,需要先删除在重新初始化。