restore / repair / reset mysql root privileges
Wer in die Situation kommt dem MySQL root User alle Rechte entnommen zu haben steckt in einer echten Zwickmühle. Im Internet findet man viele Anleitungen zum zurücksetzen des root Passworts. Aber für einen Reset der Rechte? Fehlanzeige! Folgende Schritte sind zum Reset notwendig:
Folgendes Script kann dir dabei sehr hilfreich sein:
#!/bin/bash # mysql-reset-root-privileges.sh # Simple script to restore / repair / reset mysql root privileges # # Created by Patrick Niebeling on 10-08-2010. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # You may obtain a copy of the License at: # http://www.gnu.org/licenses/gpl-3.0.txt # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You must run this script as the root user if [ `id -u` != 0 ]; then echo "You must run this script as root, and do not use sudo as it doesn't seem to work!. Aborted."; exit fi # Stop MySQL and start MySQL with skip-grant-tables /etc/init.d/mysql stop mysqld --skip-grant-tables & # Update privileges for root user mysql -vv < <-EOF update mysql.user set Super_priv='y' where user='root'; update mysql.user set Select_priv='y' where user='root'; update mysql.user set Insert_priv='y' where user='root'; update mysql.user set Update_priv='y' where user='root'; update mysql.user set Delete_priv='y' where user='root'; update mysql.user set Create_priv='y' where user='root'; update mysql.user set Drop_priv='y' where user='root'; update mysql.user set Reload_priv='y' where user='root'; update mysql.user set Shutdown_priv='y' where user='root'; update mysql.user set Process_priv='y' where user='root'; update mysql.user set File_priv='y' where user='root'; update mysql.user set Grant_priv='y' where user='root'; update mysql.user set References_priv='y' where user='root'; update mysql.user set Index_priv='y' where user='root'; update mysql.user set Alter_priv='y' where user='root'; update mysql.user set Show_db_priv='y' where user='root'; update mysql.user set Super_priv='y' where user='root'; update mysql.user set Create_tmp_table_priv='y' where user='root'; update mysql.user set Lock_tables_priv='y' where user='root'; update mysql.user set Execute_priv='y' where user='root'; update mysql.user set Repl_slave_priv='y' where user='root'; update mysql.user set Repl_client_priv='y' where user='root'; update mysql.user set Create_view_priv='y' where user='root'; update mysql.user set Show_view_priv='y' where user='root'; update mysql.user set Create_routine_priv='y' where user='root'; update mysql.user set Alter_routine_priv='y' where user='root'; update mysql.user set Create_user_priv='y' where user='root'; EOF # Restart MySQL /etc/init.d/mysql restart
Je nach Distribution können sich die Dateinamen unterscheiden. Die Nutzung erfolgt auf eigene Gefahr. Desweiteren übernehme ich keine Haftung für Schäden die durch das Script verursacht werden.
Hinterlasse einen Kommentar
An der Diskussion beteiligen?Hinterlasse uns deinen Kommentar!