MySQL root problems (access denied for root user)

MySQLpermissionsroot

I've having some very weird issues with my MySQL (5.5) root user. I'm trying to allow an external host to access the root user, but it seems as though my root@localhost does not have "GRANT OPTION" to the local databases! I think the issue at this point is caused by the fact that I think I have two root@localhost users, both with different grant rules, but I can't figure out how to get back into my install.

I've already tried deleting the root user and recreating it (I think), resetting the root users password (modifying the mysql database itself)

I can't get into the root account using the password I've always specified but rather an alternate password, which I don't even know how I got… this alternate user is the one that doesn't seem to have full root permissions, yet is still called root.

–SOLUTION POSTED BELOW–

Best Answer

You can start MySQL with the authentication disabled. From there you can create/delete the administrative account for MySQL.

The details you can find in the MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/resetting-permissions.html

  1. Shutdown MySQL

  2. Start MySQL with: mysqld --skip-grant-tables --skip-networking

  3. In mysql run:

    UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';
    

    For newer MySQL versions:

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
    GRANT ALL PRIVILEGES ON \*.\* TO 'root'@'localhost' WITH GRANT OPTION;
    
  4. Shutdown MySQL

  5. Start MySQL as you usually do.