安装 CDH执行scm_prepare_database.sh报错,java.sql.SQLException: Access denied for user ‘scm‘@‘localhost‘

1、安装CDH报错

CDH是Cloudera Distribution for
Hadoop的缩写,是一套由Cloudera提供的面向企业的开源Hadoop生态系统解决方案。CDH整合了各种Hadoop相关的开源项目和工具,并提供了集中管理和操作这些组件的功能。

安装 CDH执行scm_prepare_database.sh报错,java.sql.SQLException: Access denied for user ‘scm’@‘localhost’

 /opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm 123456

JAVA_HOME=/usr/lib/jvm/jre-openjdk Verifying that we can write to
/etc/cloudera-scm-server Creating SCM configuration file in
/etc/cloudera-scm-server Executing: /usr/lib/jvm/jre-openjdk/bin/java
-cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/opt/cloudera/cm/schema/…/lib/*
com.cloudera.enterprise.dbutil.DbCommandExecutor
/etc/cloudera-scm-server/db.properties com.cloudera.cmf.db. Tue Jul 18
20:35:55 CST 2023 WARN: Establishing SSL connection without server’s
identity verification is not recommended. According to MySQL 5.5.45+,
5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing
applications not using SSL the verifyServerCertificate property is set
to ‘false’. You need either to explicitly disable SSL by setting
useSSL=false, or set useSSL=true and provide truststore for server
certificate verification. [ main]
DbCommandExecutor INFO Unable to login using supplied
username/password. [ main] DbCommandExecutor
ERROR Error when connecting to database. java.sql.SQLException: Access
denied for user ‘scm’@‘localhost’ (using password: YES) at
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:864)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1707)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1217)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2189)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2220)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:768)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)[mysql-connector-java.jar:5.1.49]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)[:1.8.0_262] at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_262]
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_262]
at
java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_262]
at
com.mysql.jdbc.Util.handleNewInstance(Util.java:403)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)[mysql-connector-java.jar:5.1.49]
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)[mysql-connector-java.jar:5.1.49]
at
java.sql.DriverManager.getConnection(DriverManager.java:664)[:1.8.0_262]
at
java.sql.DriverManager.getConnection(DriverManager.java:247)[:1.8.0_262]
at
com.cloudera.enterprise.dbutil.DbCommandExecutor.testDbConnection(DbCommandExecutor.java:263)[db-common-6.3.1.96818eaab0a222aa84a7854b8d22c0c7.jar:]
at
com.cloudera.enterprise.dbutil.DbCommandExecutor.main(DbCommandExecutor.java:139)[db-common-6.3.1.96818eaab0a222aa84a7854b8d22c0c7.jar:]
[ main] DbCommandExecutor ERROR
Exiting with exit code 8
–> Error 8, giving up (use --force if you wish to ignore the error)

查看一下配置文件

```powershell
cat /etc/cloudera-scm-server/db.properties
Auto-generated by scm_prepare_database.sh on 2023年 07月 18日 星期二 20:35:55 CST

#

For information describing how to configure the Cloudera Manager Server

to connect to databases, see the "Cloudera Manager Installation Guide."

#
com.cloudera.cmf.db.type=mysql
com.cloudera.cmf.db.host=localhost
com.cloudera.cmf.db.name=scm
com.cloudera.cmf.db.user=scm
com.cloudera.cmf.db.setupType=EXTERNAL
com.cloudera.cmf.db.password=123456

登录MySQL

mysql -h 127.0.0.1 -P 3306 -u root -p

 Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.42 MySQL Community Server (GPL)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

授予权限

mysql> grant all privileges on . to ‘root’ @‘%’ identified by ‘123456’;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all on scm. to ‘scm’@‘%’ identified by ‘123456’;*
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> exit;
Bye

重新执行scm_prepare_database.sh

/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm scm 123456

解决问题

JAVA_HOME=/usr/lib/jvm/jre-openjdk
Verifying that we can write to /etc/cloudera-scm-server
Creating SCM configuration file in /etc/cloudera-scm-server
Executing:  /usr/lib/jvm/jre-openjdk/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/opt/cloudera/cm/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
Tue Jul 18 17:01:34 CST 2023 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
[                          main] DbCommandExecutor              INFO  Successfully connected to database.
All done, your SCM database is configured correctly!

你可能感兴趣的:(数据库,BigData,数据库,java,开发语言,大数据)