我不小心从mariadb中删除了我唯一用户的dba特权,现在我不能使用我的银行,我也无法使用linux shell centos 7恢复特权。
我试过的命令:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
退货:
# 1045 - Access denied for user 'root'@'localhost' (using password: YES)
有人经历过吗?
2条答案
按热度按时间cfh9epnr1#
停止mariadb服务器
sudo systemctl stop mariadb
在没有权限检查的情况下重新启动数据库-更多sudo mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root
输入密码重新加载grant表
Mariadb[MYSQL]> FLUSH PRIVILEGES
```insert into user (Host, User, Password, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv, File_priv, Grant_priv, References_priv, Index_priv, Alter_priv, Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv, Execute_priv, Repl_slave_priv, Repl_client_priv, Create_view_priv, Show_view_priv, Create_routine_priv, Alter_routine_priv, Create_user_priv, ssl_type, ssl_cipher, x509_issuer, x509_subject, max_questions, max_updates, max_connections, max_user_connections)
values('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','','0','0','0','0');
dced5bon2#
错误的假设是主机名的通配符还包括localhost,因此尝试通过socket(localhost)连接将失败:
使用localhost创建用户时,一切正常:
同样从mariadb server 10.4(posix平台)开始,根用户的默认身份验证方法(通过localhost连接时)通过unix\u socket插件进行。这允许root@localhost 用户无需密码即可通过socket系统变量定义的本地unix socket文件登录,只要尝试从操作系统根用户帐户拥有的进程登录:
因此以root身份正常登录将失败:
以root(sudo)身份运行时,登录按预期工作: