LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Mysql Adding back root user? (https://www.linuxquestions.org/questions/linux-software-2/mysql-adding-back-root-user-585164/)

wh33t 09-16-2007 06:29 PM

Mysql Adding back root user?
 
I stupidly deleted my root user from my mysql database server. How do I add it back?

traene 09-17-2007 11:51 AM

Sorry, i have only suggestions.
- can you connect to mysql via a socket? Do you have add users privelege with one user?
- do you have a backup of the mysql database? (/var/lib/mysql/mysql/...)
- maybe just try a mysql db of another installation (same version numbers)

archtoad6 09-17-2007 02:37 PM

If all else fails, you can:
  1. boot a live CD distro, like Knoppix
  2. become root (easy in Knoppix)
  3. cd & chroot to '/' of the damaged installation
  4. recreate the root acct. w/ useradd or adduser
    NB: Pay attention that the UID of the recreated acct. is 0

archtoad6 10-25-2007 11:41 AM

Did that work?

If it did, we'd like the positive feedback; if not, then we'd like to figure out why not & also you help find a solution.

wh33t 10-25-2007 01:52 PM

Sorry. I never went ahead and tried the solutions offered. I just re-installed Ubuntu and Mysql as there wasn't anything I was afraid to lose on the machine yet.

archtoad6 10-25-2007 04:05 PM

Sometimes that is the easiest way, even if you learn less doing it like that than struggling further w/ the original problem.

Wim Sturkenboom 10-26-2007 12:00 AM

For the next time, start mysqld with the skip-grant-tables option
Quote:

--skip-grant-tables

This option causes the server not to use the privilege system at all. This gives anyone with access to the server unrestricted access to all databases. You can cause a running server to start using the grant tables again by executing mysqladmin flush-privileges or mysqladmin reload command from a system shell, or by issuing a MySQL FLUSH PRIVILEGES statement. This option also suppresses loading of user-defined functions (UDFs).
Read the manual ;)


All times are GMT -5. The time now is 12:48 PM.