MySQL: Accidently Removed Both root users

[CENTER]:notme: Never underestimate the power of a motivated idiot!!! :notme:[/CENTER]

I managed accidentally remove both BOTH root MySQL using phpMyAdmin (You should have seen my face when it printed out the commands it sent… :/)

oh :swear:!

i tried using /usr/bin/mysqld_safe --user=root but phpmyadmin still wont let me login…

help!

Note: I am using Ubuntu, but i CAN login as root!

Look here: SitePoint Forums - Deleted the root user :frowning:

[CENTER]:notme: Never underestimate the power of a motivated idiot!!! :notme:[/CENTER][center]:doh: too true:doh: [/center][ot]i’ve done some idiotic thing too, i only realize how stupid i was after the event[/ot]

Success :smiley:

Thanks Addis, doubt i would have found “–init-file=temp” without that.

If anybody else manages this, then here’s how you can sort it…

  1. create a text file called “temp” containing the following line and put it in your home folder.
GRANT ALL PRIVILEGES ON *.* TO 'bob'@'%'
  1. Kill mysql (You will need to do this as root or with sudo)
/etc/init.d/mysql stop
  1. start mysql with the following command, replace ‘impotence’ with the name of your home folder.
mysqld --init-file=/home/impotence/temp

congrats, you created a fully privileged user called bob (with no password) that can be logged into from anywhere!

get everything back the way it was and then delete bob!

Glad you got it sorted :).