问题一、mysql的安装目录在哪里
现在版本的mysql,安装后分散到多个目录,可以通过find 命令获取相关目录信息
[root@archive ~]# find / -name mysql -print
/opt/hadoop/apache-hive-2.1.0-bin/scripts/metastore/upgrade/mysql
/var/lib/mysql
/var/lib/mysql/mysql
/var/lock/subsys/mysql
/usr/bin/mysql
/usr/lib64/mysql
/usr/share/mysql
/etc/logrotate.d/mysql
/etc/rc.d/init.d/mysql
/home/soft/mysql
问题二、 mysql 数据库的重建
如果MySQL不能启动了,库损害了,或者密码忘记了,而数据库里面又没有重要数据,可以这样重建MySQL数据库:
1、用root用户操作:
/etc/init.d/mysql stop #先停止
2、rm -rf /var/lib/mysql #删除所有数据库
3、mysql_install_db #重新建库
4、修改mysql、test两个目录及目录下所有文件的权限: (这个/var/lib/mysql目录下)
chown mysql:mysql -R mysql test
注意这里一定要加上-R参数,否则启动会报错
5、启动数据库
./mysqld_safe --user=mysql &
6、修改root密码
mysql/bin/mysqladmin -u root password "yourpasswd"
问题三、Starting MySQL. ERROR! The server quit without updating PID file
检查 archive.cloudera.com.err ,可以发现是 /usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13 - Permission denied),所以判断是权限问题
[root@archive lib]# chown -R mysql:mysql mysql
[root@archive lib]#
[root@archive lib]# chown -R mysql:mysql /usr/share/mysql
[root@archive lib]#
[root@archive lib]# chown -R mysql:mysql /var/lock/subsys/mysql
问题四、hive采用本地mysql方式时,异常 ("com.mysql.jdbc.Driver") was not found
启动mysql,如果出现下面异常
Caused by: org.datanucleus.exceptions.NucleusException: Attempt to invoke the "BONECP" plugin to create a ConnectionPool gave an error : The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH. Please check your CLASSPATH specification, and the name of the driver.
解决:
下载mysql-connector-java-5.1.6-bin.jar
拷贝到mysql的lib目录:cp *jar /opt/hadoop/hive/lib
问题五、hive采用本地mysql方式,异常Access denied for user 'hive'@'archive.cloudera.com' (using password: YES)
java.sql.SQLException: Unable to open a test connection to the given database. JDBC url = jdbc:mysql://192.168.136.144:3306/hive?characterEncoding=UTF-8, username = hive. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: Access denied for user 'hive'@'archive.cloudera.com' (using password: YES)
解决: 这个情况其实有很多原因会导致,这里提两种情况
1、权限问题
#首先用root登录mysql
mysql -uroot -pnmc123
#登录后进行授权
grant all on *.* to 'hive'@'archive.cloudera.com' identified by'hive'
grant all on *.* to hive@'%' identified by 'hive';
flush privileges;
#重启mysql
service mysql restart
#确认
mysql -uhive -phive
#登录后,使用数据库
use mysql
#如果不报错,就成功了。
2、 hive版本问题,有可能是hive版本不匹配导致,我自己就因为hive版本太高,也会报这个错,重新装一个低版本的就可以。
hadoop 2.6.4 +hbase 1.0.3 + hive 2.0.0
问题五: ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
解决:登录后,执行 SET PASSWORD = PASSWORD('nmc123'); 可以解决