Support Questions
Find answers, ask questions, and share your expertise

scm_prepare_database.sh failure

Explorer

Hello,

 

I have installed mysql database as external database and I'm trying to run scm_prepare_database.sh script and I get this error;

 

[root@cm mysql]# /usr/share/cmf/schema/scm_prepare_database.sh mysql -h localhost -u temp -p --verbose scmdb scmuser
Enter database password:
Enter SCM password:
JAVA_HOME=/usr/java/jdk1.8.0_171-amd64/
Verifying that we can write to /etc/cloudera-scm-server
Database type: mysql
Database user: temp
Executing: /usr/java/jdk1.8.0_171-amd64//bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbProvisioner --create -h localhost -u temp -H localhost -U scmuser -d scmdb -t mysql
[ main] DbProvisioner ERROR Exception when creating/dropping database with user 'temp' and jdbc url 'jdbc:mysql://localhost/?useUnicode=true&characterEncoding=UTF-8'
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.Util.getInstance(Util.java:386)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2570)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2306)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:839)[mysql-connector-java.jar:]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)[mysql-connector-java.jar:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:421)[mysql-connector-java.jar:]
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:350)[mysql-connector-java.jar:]
at java.sql.DriverManager.getConnection(DriverManager.java:664)[:1.8.0_171]
at java.sql.DriverManager.getConnection(DriverManager.java:247)[:1.8.0_171]
at com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java:296)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.doMain(DbProvisioner.java:104)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.main(DbProvisioner.java:123)[db-common-5.15.0.jar:]
[ main] DbProvisioner ERROR Stack Trace:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.Util.getInstance(Util.java:386)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2570)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2306)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:839)[mysql-connector-java.jar:]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)[mysql-connector-java.jar:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:421)[mysql-connector-java.jar:]
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:350)[mysql-connector-java.jar:]
at java.sql.DriverManager.getConnection(DriverManager.java:664)[:1.8.0_171]
at java.sql.DriverManager.getConnection(DriverManager.java:247)[:1.8.0_171]
at com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java:296)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.doMain(DbProvisioner.java:104)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.main(DbProvisioner.java:123)[db-common-5.15.0.jar:]
--> Error 1, giving up (use --force if you wish to ignore the error)

 

Could you help me on this?

 

Best regards,

 

Huriye

14 REPLIES 14

Expert Contributor
I cannot see any clear indication in the logs, other than connection to mysql failed for some reason. mysql java connector seem to be in place. Have you installed mysql with default options? Port 3306? If for example, you have used 3307, then you should also specify "-P 3307". I recommend to specify it, even if you are using the default port. Have you granted permissions to "temp" user according to instructions? PS: since your mysql is on localhost, you do not need to define another user and you can use root /usr/share/cmf/schema/scm_prepare_database.sh mysql -h localhost -u root -p --verbose scmdb scmuser

Explorer

Hello,

Thank you for the response. I have installed mysql with default options, even if I specify the port I still get the same error. I also tried to run the script by using root user, I still get the same error.

Thanks,

Huriye

Expert Contributor

Can you try

mysql -h localhost -u temp -p

just to verify that mysql server accepts connections?

 

Also, can you check if SELinux is enabled?

getenforce

If the output is "1" then you should disable it.

Temp change

setenforce 0

Explorer

Hello,

 

I can access to mysql with temp user and I have disabled selinux before. I get the output in below;

 

[root@cm ~]# mysql -h localhost -u temp -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.11 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

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> exit
Bye
[root@cm ~]# getenforce
Disabled

 

Thanks,

 

Huriye

Super Guru

@Huriye,

 

Try using tcpdump to see if a connection is established with mysql

 

for example:

 

# tcpdump -i any -w ~/mysql.pcap port 3306

 

Run that while using scm_prepare_database.sh and find out if the connection is being made.

 

You can open mysql.pcap in WireShark to view the packets,etc.

 

If it is, check mysql logs for clues if the connection is being made at the TCP level but the server is rejecting the connection for some reason.

Explorer

Hello,

 

I run the tcpdump command, the output is in below;

 

[root@cm ~]# tcpdump -i any -w ~/mysql.pcap port 3306
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes

 

There is no error in mysqld.log and mysql.log.

 

Do you have any idea?

 

Thanks,

 

Huriye

Expert Contributor
I suppose that you have followed Cloudera's instructions and created the temp user with the command below: mysql> grant all on *.* to 'temp'@'%' identified by 'temp' with grant option; Which is fine. In that case you should use the actual hostname instead of localhost. In mysql "%" does not always include "localhost".

Explorer

Hello,

 

I checked if root is belong to local host and I tried to run with root user and localhost but got the same error. 

 


mysql> SELECT User, Host FROM mysql.user;
+------------------+-----------+
| User | Host |
+------------------+-----------+
| reportmanager | % |
| temp | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
6 rows in set (0.01 sec)

mysql> exit
Bye

 

 

 

 

[root@cm ~]# /usr/share/cmf/schema/scm_prepare_database.sh mysql -h localhost -u root -p 3306 --verbose scmdb scmuser
Enter database password:
JAVA_HOME=/usr/java/jdk1.8.0_171-amd64/
Verifying that we can write to /etc/cloudera-scm-server
Database type: mysql
Database user: root
Executing: /usr/java/jdk1.8.0_171-amd64//bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbProvisioner --create -h localhost -u root -H localhost -U scmdb -d 3306 -t mysql
[ main] DbProvisioner ERROR Exception when creating/dropping database with user 'root' and jdbc url 'jdbc:mysql://localhost/?useUnicode=true&characterEncoding=UTF-8'
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.Util.getInstance(Util.java:386)[mysql-connector-java.jar:]

Super Guru

@Huriye,

 

You need to view the pcap file in WireShark and check to see what's going on.  The exception that is displayed does not tell the entire story, stack-wise.  Usually there is a caused by that shows "connection refused" or something else.  I'm not sure why we don't see that in this case.

 

I suggest using some test code outside Cloudera Manager to test as the stack trace indicates there are problems connecting via Java.

 

There are example sources everywhere... this one I think is pretty simple.  You could compile after making the JDBC url look like is formulated by scm_prepare_database.sh

 

http://www.vogella.com/tutorials/MySQLJava/article.html

 

At the least this may give us the full stack trace.

Explorer

Hello,

 

I dont know how exactly I can use the test code. I dont have java know-how.

 

Thanks,

 

Huriye

Super Guru

@Huriye,

 

You can also review tcpdump output to see if a conneciton is being made.  Check your mysql logs to see if a connection attempt is registered, etc.

 

Somewhere between the JDBC driver and your mysql server there is a failure of some sort, so diagnostics need to be performed to figure out what is failing.

 

This may take some digging, so if you have friends, colleagues, etc. who can work with you on this system and know how to debug these sort of connection issues, I'd ask them for some help.

 

I was suggesting the java app to test as an example of something you might try, but if it is outside your skillset, then there may be other ways.

 

Start by seeing if you can determine if the JDBC connection is able to reach its destination (mysql server).

Explorer

Hello,

 

I resolved the error which wasa "Unable to find jdbc" by defining the full jar file name in /etc/defaul/cloudera-scm-server. But now I am getting another issue which is; 

 

[ main] DbProvisioner ERROR Exception when creating/dropping database with user 'root' and jdbc url 'jdbc:mysql://localhost/?useUnicode=true&characterEncoding=UTF-8'
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'Support123*'' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:790)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:675)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java:299)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.doMain(DbProvisioner.java:104)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.main(DbProvisioner.java:123)[db-common-5.15.0.jar:]
[ main] DbProvisioner ERROR Stack Trace:
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'Support123*'' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:790)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:675)[mysql-connector-java-8.0.11.jar:8.0.11]
at com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java:299)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.doMain(DbProvisioner.java:104)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.main(DbProvisioner.java:123)[db-common-5.15.0.jar:]
--> Error 1, giving up (use --force if you wish to ignore the error)

 

I have changed the password and tried again but getting the same error. 

 

Could you help me on this please?

 

Thanks,

 

Huriye

Super Guru

@Huriye,

 

I could be wrong, but now it appears to be breaking earlier (before a connection is attempted).

Also, I note dthat you are using mysql-connector-java-8.0.11.jar which we do not currently support and we know will cause problems if you are able to get past this problem.  What command line did you use to generate this error... it appears the error is saying there is a problem with the syntax of the query and the query is generated based on the options you supplied.  Is it possible you have mismatched quotes around your password?

Explorer

Hello,

 

I changed the jar file name as mysql-connector-java.jar then I get error which password is not suitable for the policy. But removed my redhat machines and created Centos. Now I dont have any error to connecting mysql database. 

I still dont know what was the problem.

 

Thanks,

 

Huriye

; ;