Deleted root user from phpmyadmin - MAMP

Hi all

I’ve accidental deleted my root user from mysql using MAMP inside my phpadmin. I can’t view, add or delete any databases, though I can still update and view sites running locally.

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

Been trying to fix this for hours… can anybody help?

Initial setup was
u: root p: root

I’ve updated config.inc.php, index.php and stopMysql.sh and removed the root password to no password.

How can I add the main root user back into mysql?
Any help much appreciated.

Thanks, Barry

Can your ISP do it for you? Or Hosting company?

This is a local installation, hence MAMP.

Thanks, Barry

In that case it sounds like a re-install. Unless there is a hack.

Buddy

This is what I’m trying to avoid, I have lost of databases already setup, multiple Drupal installations and lots of other stuff. Surely there must be a way?

As I mentioned, I can still update and modify local sites running on the server, its just when I try and access the phpadmin and DB. I need to somehow add the root user back into the mix.

Barry

What permissions do your other users have? Do they have FULL permissions? Or a limited amount of permissions so they can’t do any harm to the database?

There are no other users.
Its basically all my work, developments and testing server I’m running and using locally.

FULL permissions was for me, I’ve deleted the user with ALL privileges [me] and now can’t access anything?

Thanks, Barry

there’s not even the pma user (own user for phpMyAdmin)?

The pma user is the root user, that’s me.

?

Thanks, Barry

I didn’t realize phpMyAdmin would let you delete your own account… I thought there were safe guards around that.

This is a long shot, but have you tried accessing your phpMyAdmin using localhost or 127.0.0.1 and still login as root?

Last I knew phpMyAdmin setup an account for each host (or something funky like that). Or maybe you deleted the host reference and 127.0.0.1 or localhost is still accessible.

Also check if there is a mysql user you can login as on the system and use to access mysql…

Last but not least. Find your MySQL Data directory, back it up, re-install MySQL, and there may be a way to get to the data of the backup files.

I thought there were safeguards around that.

It was deleted by accident, I wish there was a safeguard, causing me lots of work trying to fix it.

localhost/MAMP/?language=English

As above, this is the url that shows the admin area, its when I click the phpadmin tab, the error shows.

Also check if there is a mysql user you can login as on the system and use to access mysql…

This was my initial thought, funny enough I created a user with full privileges just before I deleted the root user. I’m just not sure how I retrieve this user or find the details so I can update the files?
I can’t remember what I called it. Do you know how?

Find your MySQL Data directory, back it up, re-install MySQL, and there may be a way to get to the data of the backup files.

This is my last resort if all else fails.

Thanks, Barry

Fixed it! :smile:
Been hard at it for the past 2-3 hours.

I managed to get access to the mysql server through the terminal on my mac. After much trial and error I deleted the instance of the root user and created a fresh, with new passwords and full privileges.

I then needed to update about 6 files located inside the /MAMP/Library/bin/… updating the passwords.

Restarted the servers and bingo!
Everything is now working with full access to the databases and phpadmin :smile:

Hopefully this will help somebody else.

You’ll need to do some research for the mysql server commands…
Then have a look at the reference below for details on how to update the MAMP files.
https://teamtreehouse.com/forum/mamp-phpmyadmin-error-1045-after-i-changed-my-root-password-not-sure-how-to-change-it-backreset

Barry

3 Likes

Great job! Persistence paid off!