I'm using phpMyAdmin to manage my databases, I have 2 projects that use 2 different database the first one uses 'root'@'localhost' and the 2nd is 'root'@'127.0.0.1' I don't know how i ended up using 2 different server but it was working fine until i tried to edit codes with the 1st project that uses 'root'@'localhost', I was trying to select from a table to be loaded to a DataGridView when an error popped up saying "Host 'hostname' is not allowed to connect to this MySQL server". The 2nd project is working fine. This only happened after I try to create a module for connecting to mysql database since the earlier code for connecting to mysql is written in every form.

I went to the mysql.user table to check if i can edit users and passwords, I tried. But any command that I try to do won't work, after getting back to my databases, when i try to select anything phpMyAdmin says "No database selected". After closing and opening it again every single database is all gone.

I don't know where i f'd up. I'm sorry if this is a dumb question to ask I just really need help. I'm already thinking uninstalling and reinstalling wamp and then recreating all the lost database but im still hoping there is another workaround here.

Dani AI

Generated

Short diagnosis and do-not-do first: this usually isn’t “all files deleted” — it’s far more likely you removed or changed privileges when editing mysql.user, so phpMyAdmin (connected as root@localhost) can no longer see databases. is correct that 127.0.0.1 and localhost are treated as different MySQL accounts; that explains why your second project (root@127.0.0.1) still works while the other does not. Do not reinstall or overwrite WAMP yet — that can make recovery harder.

Immediate checklist (do these now)

  • Stop MySQL cleanly (WAMP tray -> MySQL -> Stop service or Services.msc).
  • Make a full copy of the MySQL data directory before changing anything. Find my.ini (WAMP -> MySQL -> my.ini) and note the datadir, then copy that folder somewhere safe.
  • Look inside the data folder: do you still see subfolders named for your databases and the mysql system schema? If yes, your data files are still present.

If data folders exist but phpMyAdmin shows nothing

  • The quickest fix is to restore a working root account or grants instead of editing mysql.user manually. If you can connect with root@127.0.0.1, log in and run:
    SELECT User,Host FROM mysql.user;
    SHOW GRANTS FOR 'root'@'127.0.0.1';
    SHOW DATABASES;
  • If root@localhost is missing or has no privileges, start MySQL with grants disabled, fix users, then restart normally. Example (Windows):
    # stop MySQL, then run from MySQL bin:
    mysqld --skip-grant-tables --skip-networking
    # in another console:
    mysql -u root
    # then restore safe grants:
    CREATE USER IF NOT EXISTS 'root'@'localhost' IDENTIFIED BY 'your_pass';
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
    FLUSH PRIVILEGES;

    (Warning: --skip-grant-tables disables auth; remove it and restart MySQL after fixing.)

If folders are missing or InnoDB errors appear

  • Check the MySQL error log in the data dir for messages. Look for deleted files, permission errors, or InnoDB corruption. If InnoDB is corrupted you can temporarily set innodb_force_recovery=1 (increase only if necessary) to start and dump data with mysqldump.

Extra tips: check Windows file permissions and antivirus/quarantine, and do not edit mysql.user rows directly — use CREATE USER/GRANT/ALTER USER. If you post the output of the error log and the SELECT User,Host FROM mysql.user; result, someone here can give the exact next commands.

Recommended Answers

All 3 Replies

localhost and 127.0.0.1 should point to the same location. 127.0.0.1 is the IP address for localhost, your local machine.

Thank you for the replies! Will these get back my missing databases i tried both nothing happened

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.