Nothing is true, everything is permitted

Nothing is true. Everything is permitted.

To say that nothing is true, is to realize that the foundations of society are fragile, and that we must be the shepherds of our own civilization. “Nothing is true” asks you to question every fact you know as they are constant buried in lies.

To say that everything is permitted, is to understand that we are the architects of our actions, and that we must live with their consequences, whether glorious or tragic. “Everything is permitted” suggests that even things you believe to be impossible are not necessarily so, you just lack the vision to see them to fruition.

No MySQL users after fresh install in RHEL 6.6

MySQL Logo

I had a fresh install of RHEL 6.6 with MySQL 5.1.73. When i tried to reset MySQL root password for MySQL, it hadn’t worked. Reason was, that mysql.user table was empty, there was no ‘root’ user created.

Following helped me to resolve the issue:

  1. Restart MySQL like this:
    service mysqld restart --skip-grant-tables
     
  2. Enter MySQLfrom the command line (no password needed at this point)
    # mysql
     
  3. Do desc mysql.user
     

    You will see 17 rows for MySQL 4.1
    You will see 37 rows for MySQL 5.0
    You will see 39 rows for MySQL 5.1
    You will see 42 rows for MySQL 5.5

    You will have to tweak each privilege since the GRANT command does not work will skip-grant-tables is enabled

  4. For MySQL 5.1, you can enter a new root@localhost whose password is ‘whatever’ as follows:
     
    DELETE FROM mysql.user WHERE user='root' AND host='localhost';
    INSERT INTO mysql.user SET
                      Host = 'localhost',
                      User = 'root',
                  Password = PASSWORD('whatever'),
               Select_priv = 'Y',
               Insert_priv = 'Y',
               Update_priv = 'Y',
               Delete_priv = 'Y',
               Create_priv = 'Y',
                 Drop_priv = 'Y',
               Reload_priv = 'Y',
             Shutdown_priv = 'Y',
              Process_priv = 'Y',
                 File_priv = 'Y',
                Grant_priv = 'Y',
           References_priv = 'Y',
                Index_priv = 'Y',
                Alter_priv = 'Y',
              Show_db_priv = 'Y',
                Super_priv = 'Y',
     Create_tmp_table_priv = 'Y',
          Lock_tables_priv = 'Y',
              Execute_priv = 'Y',
           Repl_slave_priv = 'Y',
          Repl_client_priv = 'Y',
          Create_view_priv = 'Y',
            Show_view_priv = 'Y',
       Create_routine_priv = 'Y',
        Alter_routine_priv = 'Y',
          Create_user_priv = 'Y',
                Event_priv = 'Y',
              Trigger_priv = 'Y',
                  ssl_type = '',
                  ssl_cipher = '',
                 x509_issuer = '',
                x509_subject = '',
               max_questions = 0,
                 max_updates = 0;

  5. Restart MySQL
    service mysqld restart

Source: Database Administrators Stack Exchange