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

java.sql.SQLException: Access denied for user 'root'@'d001' (using password: YES)

时间:2019-06-11 12:44:21      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:not   print   current   ace   word   cee   core   grant   ica   

在安装CDH的时候报错了:

root@d001:/var/cache/yum/x86_64/7/base# /opt/cm-5.13.0/share/cmf/schema/scm_prepare_database.sh mysql cdh -hd001 -uroot -proot  -pwordemotion  --scm-host d001 root root --force
JAVA_HOME=/soft/jdk1.8.0_144
Verifying that we can write to /opt/cm-5.13.0/etc/cloudera-scm-server
[                          main] DbProvisioner                  ERROR Exception when creating/dropping database with user root and jdbc url jdbc:mysql://d001/?useUnicode=true&characterEncoding=UTF-8
java.sql.SQLException: Access denied for user root@d001 (using password: YES)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:873)
        at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1710)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2191)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2222)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2017)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java:296)
        at com.cloudera.enterprise.dbutil.DbProvisioner.doMain(DbProvisioner.java:104)
        at com.cloudera.enterprise.dbutil.DbProvisioner.main(DbProvisioner.java:123)
[                          main] DbProvisioner                  ERROR Stack Trace:
java.sql.SQLException: Access denied for user root@d001 (using password: YES)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:873)
        at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1710)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226)
        at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2191)
        at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2222)
        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2017)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:779)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:389)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java:296)
        at com.cloudera.enterprise.dbutil.DbProvisioner.doMain(DbProvisioner.java:104)
        at com.cloudera.enterprise.dbutil.DbProvisioner.main(DbProvisioner.java:123)
--> Error 1, ignoring (because force flag is set)
Creating SCM configuration file in /opt/cm-5.13.0/etc/cloudera-scm-server
Executing:  /soft/jdk1.8.0_144/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/opt/cm-5.13.0/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /opt/cm-5.13.0/etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
[                          main] DbCommandExecutor              INFO  Successfully connected to database.
All done, your SCM database is configured correctly!

 

我们研究一下 scm_prepare_database.sh的参数

 /opt/cm-5.13.0/share/cmf/schema/scm_prepare_database.sh --help
usage: /opt/cm-5.13.0/share/cmf/schema/scm_prepare_database.sh [options] (postgresql|mysql|oracle) database username [password]

Prepares a database (currently either MySQL, PostgreSQL or Oracle)
for use by Cloudera Service Configuration Manager (SCM):
o Creates a database (For PostgreSQL and MySQL only)
o Grants access to that database, by:
  - (PostgreSQL) Creating a role
  - (MySQL) Creating a grant
o Creates the SCM database configuration file.
o Tests if the database connection parameters are valid.

MANDATORY PARAMETERS
database type: either "oracle", "postgresql" or "mysql"
database: For PostgreSQL and MySQL, name of the SCM database to create.
          For Oracle this is the SID of the Oracle database.
username: Username for access to SCMs database.

OPTIONAL PARAMETERS
password: Password for the SCM user. If not provided, and --scm-password-script
          is not specified as an option, will prompt for it.

OPTIONS
   -h|--host       Database host. Default is to connect locally.
   -P|--port       Database port. If not specified, the database specific
                   default will be used: namely, 3306 for MySQL,
                   5432 for PostgreSQL, and 1521 for Oracle.
   -u|--user       Database username that has privileges for creating
                   users and grants.  The default is centos.
                   Typical values are root for MySQL and
                   postgres for PostgreSQL. Not applicable for Oracle.
   -p|--password   Database Password. Default is no password.
   --scm-host      SCM servers hostname. Omit if SCM is colocated with MySQL.
   --config-path   Path to SCM configuration files.
                   Default is /etc/cloudera-scm-server.
   --scm-password-script Instead of obtaining the SCM usernames password
                   directly, execute a script whose stdout is used as the
                   password.
   -f|--force      Dont stop when an error is encountered.
   -v|--verbose    Print more informational messages.
   -?|--help       Show this message.

NOTE ON POSTGRESQL CONFIGURATION
PostgreSQL must be configured to accept connections
with md5 password authentication.  To do so,
edit /var/lib/pgsql/data/pg_hba.conf (or similar)
to include "host all all 127.0.0.1/32 md5" _above_
a similar line that allows ident authentication.

 

 

 /opt/cm-5.13.0/share/cmf/schema/scm_prepare_database.sh mysql cdh -hd001 -uroot -proot  -pwordemotion  --scm-host d001 root root --force
调整成

/opt/cm-5.13.0/share/cmf/schema/scm_prepare_database.sh -hd001 -P3306 --scm-host d001 --force mysql cdh root root

java.sql.SQLException: Access denied for user 'root'@'d001' (using password: YES)

标签:not   print   current   ace   word   cee   core   grant   ica   

原文地址:https://www.cnblogs.com/wqbin/p/11002884.html

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