Forum Moderators: open

Message Too Old, No Replies

Revoke All Privileges, Grant Option From 'Root' @'Localhost'

Thanks phpMyAdmin!

         

ChozSun

7:23 pm on Nov 8, 2006 (gmt 0)

10+ Year Member



That is what I saw when I attempted to remove a user from a database so I can then drop the database. (I could not reproduce it if you asked me to.) Thusly, I no longer have root access to mysqld. (Thankfully, this is a development server and the sites that ran off of it had their own db account.)

My system:
======================================
MySQL 4.1.20
phpMyAdmin 2.7.0-pl2
Linux 2.6.11-1.1369_FC4smp
======================================

I have tried to restart mysqld with skip-grant-tables but alas, you cannot GRANT ALL PRIVILIGES for 'root'@'localhost' when this is done.

I have also tried running mysql_fix_privilege_tables (with and without skip-grant-tables) and that didn't fix it either.

I did have root account accessible to the FQDN but it still does not let me restore priviliges back to root@localhost.

So my questions:
1. Is there any scripts or other mysql commands I can use in order to restore rights?

2. If a reinstall is needed:
a. How do I save my databases from being wiped
b. What db/table do I need to delete in order for the reinstall to give me root@localhost rights again.

coopster

9:11 pm on Nov 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, ChozSun.

How to Reset the Root Password [dev.mysql.com]

ChozSun

9:58 pm on Nov 8, 2006 (gmt 0)

10+ Year Member



Actually I can connect just fine with --skip-grant-tables:

======================================
# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 40 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
======================================

... and without --skip-grant-tables:
======================================
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
======================================

Now obviously, with skip-grant-tables, you cannot change privileges for root:
======================================
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'goodsecret';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql>
======================================

so flush privileges and try again;
======================================
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'goodsecret';
Query OK, 0 rows affected (0.01 sec)

mysql>
======================================

But when I do that, anything that uses the root (including phpMyAdmin) does not connect.

ChozSun

3:04 pm on Nov 10, 2006 (gmt 0)

10+ Year Member



Is bumping allowed? Just wondering.

ChozSun

5:11 pm on Nov 10, 2006 (gmt 0)

10+ Year Member



So now I know what the init file can do.

My init file read like:
======================================
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'shinynewpasswd';
=====================================

My commands in shell:
======================================
shell> kill `cat /var/run/mysqld/mysqld.pid`
shell> mysqld_safe --skip-kill-mysqld --init-file=/root/mysql-init &
======================================

I kept getting the following error in my ye old phpMyAdmin:
Client does not support authentication protocol requested by server; consider upgrading MySQL client

When I looked that up, it refered me to setting OLD_PASSWORD:
======================================
shell> kill `cat /var/run/mysqld/mysqld.pid`
shell> mysqld_safe --skip-kill-mysqld --init-file=/root/mysql-init &
======================================

So I set it:
======================================
# mysql -u root -pshinynewpasswd
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 4.1.20

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> SET PASSWORD FOR
-> 'root'@'localhost' = OLD_PASSWORD('shinynewpasswd');
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye
======================================

... and I can now do root stuffs in mysql.

Thanks.

coopster

1:22 pm on Nov 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Glad you got it sorted out! Yep, that was a known issue that was hashed over here at WebmasterWorld quite a few times in the past. Here is the original discussion when 4.1 was in alpha ...
[webmasterworld.com...]