Hive integration with mysql - mysql

i already installed Hive with hadoop over Hbase, i changed the configuration of database driver from derby to MySQL, but i got this exception
FAILED: Error in metadata: javax.jdo.JDOFatalDataStoreException: Access denied for user 'DBAUSER'#'linux-96' (using password: YES)
NestedThrowables:
java.sql.SQLException: Access denied for user 'DBAUSER'#'linux-96' (using password: YES)
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
i already installed MySQL on localhost and configured hive-site.xml to read from this db
i don't know where is the problem, could anyone help?

This is question is mostly related to your MySQL configuration.
I bet that the problem is in your jdbc URL configuration. The error says is trying to connect to host linux-96 and you mentioned you have installed your MySQL server in your localhost.
First run MySQL server in your localhost and try to open a client session:
$ sudo service mysqld start
$ mysql -h localhost -u root -p
You should be able to login (if not search for how to reset MySQL root password)
Create your destination database in MySQL and a user and a password and check you can log in by command line before going ahead.
$ mysql -h localhost -u <user> -p<password> <database>
Then check you hive-site.xml configuration. You should have something like this:
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/database?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>user</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
</property>

Error strictly says, that you need to add necessary permissions to MySQL table.
Read more about MySQL permissions here: http://dev.mysql.com/doc/refman/5.5/en/grant.html
Here is useful tutorial: http://kb.mediatemple.net/questions/788/HOWTO%3A+GRANT+privileges+in+MySQL#dv

Your mysql password has changed. This is the only reason.
I have the same error, because my workmate changed mysql password without a word

Related

SonarQube analysis via Maven fails with database access denied to MySQL

I have instances of MySQL, SonarQube, and TeamCity all running on the same Linux host. All are very vanilla installations (out of the box / insecure / local / behind company firewall).
These are my Maven settings ... where ${fullyQualifiedDomainName} is something like build.company.com
<profile>
<id>env-dev</id>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<sonar.jdbc.url>jdbc:mysql://${fullyQualifiedDomainName}:3306/sonar?useUnicode=true&characterEncoding=utf8</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<sonar.host.url>http://${fullyQualifiedDomainName}:9000</sonar.host.url>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
I run the command mvn sonar:sonar to perform and upload SonarQube analysis.
The Maven settings above work OK from my Windows PC. However, if I run from the Linux server via TeamCity, I see this error: (giant Java stacktrace + ...):
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar (default-cli) on project IMQuant:
Fail to connect to database:
Cannot create PoolableConnectionFactory
(Access denied for user 'sonar'#'${fullyQualifiedDomainName}'
(using password: YES)) -> [Help 1]
If I switch to use localhost in the Maven settings it runs OK on the Linux server. I am guessing this is one of the following issues:
MySQL config (I am a MySQL newbie)
Linux server config (network config / admin stuff beyond my control)
MySQL JDBC driver bug (localhost != fqdn from localhost)
For now I am using a second Maven profile in my settings for TeamCity / Linux with localhost.
Is there a solution for this issue? Has anyone seen this issue?
Update
Here are the commands to create my MySQL database for SonarQube. As noted by #Mithfindel, it may be the root cause.
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'#'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'#'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
Ref: https://github.com/SonarSource/sonar-examples/blob/master/scripts/database/mysql/create_database.sql
It looks like a MySQL configuration issue: for MySQL, a GRANT on localhost is different from a GRANT on localhost's FQDN. You might want to check which permissions are granted to users 'sonar'#'localhost' and 'sonar'#'fqdn-of-localhost' or 'sonar'#'%'.

using mysql with hive

I am having problem in using mysql via HIVE. When I do:
hive> show tables;
FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
This is the section of the hive.log file:
2014-12-10 19:46:01,928 ERROR Datastore.Schema (Log4JLogger.java:error(125)) - Failed initialising database.
Access denied for user 'root'#'localhost' (using password: YES)
org.datanucleus.exceptions.NucleusDataStoreException: Access denied for user 'root'#'localhost' (using password: YES)
This is the section of hive-site.xml
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value></value>
</property>
but when I do the same query in MYSQL there is no problem.
The hive.log shows clearly that the issue is a failed attempt by the hive client to authenticate against the mysql database used by the hive metastore server.
You apparently do not have the correct root password for mysql. You will either need to correct the password by obtaining from the sysadmin or reset it. Following are instructions on how to reset the password:
http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html
I believe there might be 2 issues. One is your Hive service client or Hive server itself is not running. Second make sure the user has able to connect mysql.

Hive connectivity to MySQL: Access denied for user 'hive'#'localhost' hive

I am setting up Hive on CentOS, and I have installed hadoop, hive and MySQL on the same server. I have also setup metastore DB on mySQL and user ID - hive has access to the database.
I have the below issue - Error Message is given below. Can some one help to fix this issue?
show databases;
FAILED: Error in metadata: MetaException(message:Got exception: org.apache.hadoop.hive.metastore.api.MetaException
javax.jdo.JDODataStoreException: Access denied for user
'hive'#'localhost' (using password: YES)
NestedThrowables:
java.sql.SQLException: Access denied for user 'hive'#'localhost' (using password: YES))
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
Hive-site.xml is given below.
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://127.0.0.1/metastore?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>password</value>
</property>
<property>
<name>hive.hwi.war.file</name>
<value>/usr/lib/hive/lib/hive-hwi-0.10.0-cdh4.2.0.jar</value>
<description>This is the WAR file with the jsp content for Hive Web Interface </description>
</property>
<property>
<name>datanucleus.fixedDatastore</name>
<value>true</value>
</property>
<property>
<name>datanucleus.autoCreateTables</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://127.0.0.1:9083</value>
<description>IP address </description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive2/warehouse</value>
<description> warehouse </description>
</property>
I am able to login to MySQL using hive and password and able to create tables in Metastore Database. Not sure where is the issue? Any suggestions?
The above error is because of insufficient privilege for 'hive'#'localhost' in mysql server. Start mysql shell as root, then execute the following grant option there
$ mysql -u root -p -hlocalhost
Enter password:
mysql> GRANT ALL PRIVILEGES ON *.* TO 'hive'#'%' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;
The error is while granting the privileges in mySQL configuration. You should give as follows:
grant all on . to 'hive'#127.0.0.1 identified by 'YourPassword'
Since you have given the hostname as 127.0.0.1 in hive-site.xml as below:
javax.jdo.option.ConnectionURL : jdbc:mysql://127.0.0.1/metastore?createDatabaseIfNotExist=true
Just ran into this issue, share my story to anyone who might meet same scenario.
If you follow most tutorials, at first, you will set javax.jdo.option.ConnectionURL's host as localhost or 127.0.0.1.
And you also guarantee the privilege to MySQL like grant all on *.* to 'user'#localhost indentified by 'password';
As time pass by, you may need to change javax.jdo.option.ConnectionURL to remote MySQL server IP. Be sure that the user may not have the privilege to access it unless you guarantee the privilege for that specific host, namely
grant all on *.* to 'user'#remote_ip_address indentified by 'password'

Cannot connect to MySQL - host not allowed

I've just started working with Hibernate and when I'm finally trying to launch the web-app I get the following error:
2012-nov-14 12:54:23 org.hibernate.tool.hbm2ddl.SchemaExport execute
ERROR: HHH000231: Schema export unsuccessful
java.sql.SQLException: null, message from server: "Host '192.168.1.7' is not allowed to
connect to this MySQL server"
Which is really frustrating. Why aren't I a localhost? What is 192.168.1.7? I could just grant privileges like the answers to similar questions suggest but why aren't I localhost?
I understand the problem here, the hbm2ddl setting is set to create, so it wants to create the given tables but doesn't get permission from the MySQL-server.
I'm developing a struts2/hibernate app in Eclipse and I use Tomcat and of course MYSQL.
Thanks in advance!
EDIT: (hibernate.cfg.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class"> com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/clothes</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.pool_size">1</property>
<property name="dialect"> org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<!-- Needs to be disabled in production! -->
<property name="hbm2ddl.auto">create</property>
<mapping class="johanstenberg.clothes.serverobjects.AdEntity"/>
<mapping class="johanstenberg.clothes.serverobjects.AuthenticationEntity"/>
<mapping class="johanstenberg.clothes.serverobjects.UserEntity"/>
<mapping class="johanstenberg.clothes.serverobjects.VerificationKeyEntity"/>
</session-factory>
</hibernate-configuration>
Look into your hibernate configuration file. There is an entry with
<property name="connection.url"> ... </property>
You must change this entry to connect to mysql at localhost.
Next look into mysql. Connect to mysql and check privileges:
$ mysql -u root -p
mysql> show grants for 'root'#'localhost';
mysql> show grants for 'root'#'192.168.1.7';
If there are no grants for the appropriate database or tables, add them:
mysql> grant all privileges on clothes.* to 'root'#'localhost' identified by 'password';
or
mysql> grant all privileges on clothes.* to 'root'#'192.168.1.7' identified by 'password';
and then
mysql> flush privileges;
run this command on your MySQL instance (replace the tokens)
CREATE USER '${username}'#'%' IDENTIFIED BY '${password}';
GRANT ALL ON *.* TO '${username}'#'%';
this will allow you to connect to mysql from any host. 192.168.1.7 is the ip of your computer.
If you want to secure your db instance, read the this bit of the mysql documentation.
There are severals steps which you need to do:
Step1: do some configuration on my.conf
sudo vi /etc/mysql/my.cnf
bind-address = 0.0.0.0
Step2: go to mysql command(("your_remote_ip" is the pc which wants to access your mysql))
mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'your_mysql_username'#'your_remote_ip'IDENTIFIED BY 'your_mysql_password' WITH GRANT OPTION;
Step3: you can check its configuration on mysql
use mysql;
select user, host from user;
Step4: restart your mysql
sudo /etc/init.d/mysql restart

Ant couldn't connect to mysql (access denied), but mysql client could

I hava the next task in my ant file:
<target name="initdb">
<sql driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dtest"
userid="root" password="oksaoksaoksa" >
<classpath>
<pathelement path="./lib/mysql-connector-java-5.1.13-bin.jar"/>
</classpath>
<transaction src="./init.sql"/>
</sql>
</target>
When I run it, I see the error:
BUILD FAILED
/home/sbos/projects/texterra-tests/deploy.xml:43: java.sql.SQLException: Access denied for user 'root'#'localhost' (using password: YES)
However, I can login with such login and password with mysql client:
mysql -u root -p
Enter password: <oksaoksaoksa>
Welcome to the MySQL monitor. Commands end with ; or \g.
...
Why this happens? I've just installed mysql in ubuntu 10.10 if that matters
It happens because when you connect through localhost in the mysql client, it uses the unix socket to connect, which handles privileges a bit different, while ant connects to localhost through tcp/ip.
Try granting access to 127.0.0.1 (which is not the same as localhost as far as the mysql server is concerned)
grant all on initdb.* to 'root'#'127.0.0.1' identified by 'oksaoksaoksa';