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

在安装CDH的时候报错了:

[email protected]:/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 SCM‘s 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 server‘s 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 username‘s password
                   directly, execute a script whose stdout is used as the
                   password.
   -f|--force      Don‘t 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)

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

时间: 2024-11-05 19:29:21

java.sql.SQLException: Access denied for user 'root'@'d001' (using password: YES)的相关文章

连接mysql时提示java.sql.SQLException: Access denied for user &#39;root&#39;@&#39;DESKTOP-N2B2D9A&#39; (using password: YES)

用root连接mysql时提示:访问被拒绝 检查一下mysql server是否开启,发现后台在运行着..  然后查了一下mysql的用户表,发现root只能运行使用本地ip(localhost或者127.0.0.1)进行连接 解决方法:新开一个权限GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'jeffw' WITH GRANT OPTION; 然后查询一下:select * from user; 新开的root的已经开启权限,

使用mybatis生成相关文件时java.sql.SQLException: Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password)

问题:使用mybatis生成相关文件时,dos显示java.sql.SQLException: Access denied for user 'root'@'localhost' (using password) 解决方式:1,先检查数据库的配置文件密码是否错误, 2,检查mybatis-generator.xml的密码是否与数据库的密码相等,因为这个文件的密码不会影响到后台的数据,所以最容易被忽略,造成后台数据可以正常读取,而mybatis却不能生成相关的文件. 使用mybatis生成相关文件

[Spring MVC - 2A] - java.sql.SQLException: Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)

严重: Servlet.service() for servlet [springMVC] in context with path [/ExceptionManageSystem] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.Pe

java.sql.SQLException: Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password:YES)

各种错误一大堆啊,走了一个又来一个,继续吧 java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) 

java.sql.SQLException: Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO)

在更新项目之后,做了一定的改动后发现竟然报错了,刚才还好好的. java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: NO) 之后就是各种找原因.中文的关于no的这个方面资料还是比较少的.我是在一个日本的网站上看到了一些资料(不要问我为什么不goole,网限制). 总结一下吧. 1.首先去dos命令下去验证在不输入密码的情况下能不能直接登陆到mysql中 步骤:找到mysql的安装目录,

MySQL java连接被拒绝:java.sql.SQLException: Access denied for user &#39;root&#39;@&#39;****&#39; (using password: YES)

java.sql.SQLException: Access denied for user 'root'@'***.**.**.**' (using password: YES) MySQL服务器部署在Linux上,错误中被我隐掉的是我的公网IP. 这是由于"IP为***.**.**.**,名字为root"的用户 没有权限访问数据库 解决办法: 通过Navicat连接数据库,执行下面内容: grant all privileges on *.* to [email protected]

java.sql.SQLException: Access denied for user &#39;root&#39;@&#39;10.10.7.180&#39; (using password: YES)

1.刚开始连接数据库提示是: java.sql.SQLException: Access denied for user 'root'@'10.10.7.180' (using password: NO) 于是,我设置了root的密码:mysqladmin -u root password "newpwd". 注:shell> mysqladmin -u root -h host_name password "newpwd"password后面的双引号不是必须

java.sql.SQLException: Access denied for user &#39;root&#39;

程序在连接远程 mysql服务器时出错 java.sql.SQLException: Access denied for user 'root'@'192.168.27.129' (using password: YES) 本机IP为'192.168.27.129' 进入mysql命令行: MySQL>use mysql; MySQL>select host,user from user; 查看得信息如下,也没有限制不让本机连接mysql呢. +-----------------------+

Caused by: java.sql.SQLException: Access denied for user &#39;root&#39;@&#39;192.168.6.131&#39; (using password: YES),远程连接数据库,连接不上解决方案

进入 mysql   ; use mysql; 然后 执行 GRANT ALL PRIVILEGES ON *.* TO [email protected]"你.的.端.口" IDENTIFIED BY "你的密码" WITH GRANT OPTION; FLUSH PRIVILEGES; 然后成功 Caused by: java.sql.SQLException: Access denied for user 'root'@'192.168.6.131' (usi