Linux下修改mysql的密码

[root@hadoop01 bin]# schematool -initSchema -dbType mysql

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:/usr/local/hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found binding in [jar:file:/usr/local/hadoop-2.8.2/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

Metastore connection URL:  jdbc:mysql://hadoop01:3306/hive?createDatabaseIfNotExist=true

Metastore Connection Driver :  com.mysql.jdbc.Driver

Metastore connection User:  root

org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.

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

SQL Error code: 1045

Use --verbose for detailed stacktrace.

*** schemaTool failed ***

一、拥有原来的myql的root的密码;


方法一:
在mysql系统外,使用mysqladmin
mysqladmin -u root -p password "test123"
Enter password: 【输入原来的密码】

方法二:
通过登录mysql系统,
mysql -uroot -p
Enter password: 【输入原来的密码】
mysql>use mysql;
mysql> update user set password=passworD("test") where user='root';
mysql> flush privileges;
mysql> exit;      



二、忘记原来的myql的root的密码;

首先,你必须要有操作系统的root权限了。要是连系统的root权限都没有的话,先考虑root系统再走下面的步骤。
类似于安全模式登录系统,有人建议说是pkill mysql,但是我不建议哈。因为当你执行了这个命令后,会导致这样的状况:
/etc/init.d/mysqld status
mysqld dead but subsys locked
这样即使你是在安全模式下启动mysql都未必会有用的,所以一般是这样/etc/init.d/mysqld stop,如果你不幸先用了pkill,那么就start一下再stop咯。
mysqld_safe --skip-grant-tables &
&,表示在后台运行,不再后台运行的话,就再打开一个终端咯。
mysql
mysql> use mysql;
mysql> UPDATE user SET password=password("test123") WHERE user='root';   
mysql> flush privileges;
mysql> exit;                         
##本来mysql是不分大小写的,但是这个是修改的mysql中的mysql数据库的具体的值,要注意到。

发布了670 篇原创文章 · 获赞 631 · 访问量 126万+

猜你喜欢

转载自blog.csdn.net/zhangchen124/article/details/91378365
今日推荐