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

来源:互联网 发布:尽人事而知天命 编辑:程序博客网 时间:2024/05/01 22:38
授权:
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!
  






 

0 0
原创粉丝点击