hive使用过程中对mysql授权问题

本文主要介绍了在使用Hive过程中遇到的MySQL授权问题,包括如何正确授予和删除root用户的权限,以及解决'Access denied'错误的方法。通过停止服务、更新用户权限、重置密码等步骤,详细阐述了问题的解决过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

授权:
1.mysql> grant all privileges on *.* to root@'%' identified by '123456';
2.mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION ;
3.mysql>flush privileges;

删除授权:
mysql>delete from mysql.user where user="root" and host="%";

查看用户表:
SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user;
hive使用过程中对mysql授权问题 - Binder - Binder

注:
如果命令输错了,在user表中产生了一条授权,需要删除掉,不然会对再次授权有影响,可能会授权失败。

遇到的问题:
一。
mysql -uroot -p123
出现:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) hive使用过程中对mysql授权问题 - Binder - Binder
解决方法:
1.service mysqld stop
2.mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
3.mysql -u root mysql;
4.mysql> INSERT INTO mysql.user (Host,User,Password) VALUES('%','system', PASSWORD('manager'));
5.mysql> FLUSH PRIVILEGES ;

二。
ERROR 1044 (42000): Access denied for user 'root'@'%' to database 'hive' hive使用过程中对mysql授权问题 - Binder - Binder
mysql> SELECT host,user,password,Grant_priv,Super_priv FROM mysql.user;
查看user表,发现root没有权限

解决方法:
1.service mysqld stop
2.mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
3.mysql -u root mysql
4.mysql>UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
5.mysql>FLUSH PRIVILEGES;

如果是测试环境下,可以卸载数据库重新安装
完全卸载方法:
1.yum remove mysql mysql-server
2.rm -rf /var/lib/mysql
3.rm /etc/my.cnf

使用mysql自带的工具修改root用户密码方法:
$ sudo /usr/bin/mysql_secure_installation
[...]
Enter current password for root (enter for none):
OK, successfully used password, moving on...
[...]
Set root password? [Y/n] y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
[...]
Disallow root login remotely? [Y/n] N
[...]
Remove test database and access to it [Y/n] Y
[...]
Reload privilege tables now? [Y/n] Y
All done!
  






 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值