I've accidentally deleted my users table (removed all users) now whenever I try to access my database it says: "host localhost is not allowed to connect to this MYSQL Server". I've tried connecting directly, same error. I'm using apache xampp for this.
Asked
Active
Viewed 4.1k times
1 Answers
74
A very commonly asked question, try doing this (and it worked for me),
goto your mysql folder and there will be a file called my.ini. Simply add skip-grant-tables (without an argument) in the [mysqld] section as below:
[mysqld]
port=3306
skip-grant-tables
Save the file, restart your server. If the problem still exists, refer to this link.
Kate Orlova
- 2,899
- 5
- 10
- 29
Talha Tanveer
- 1,096
- 8
- 16
-
1Yup, works perfectly fine. thanks. – saasaa Jul 28 '14 at 20:19
-
2One more detail. Firewall on server computer might cause some issues with access to mysql. Just good to remember. – Alliswell Apr 13 '16 at 10:08
-
2c:\xampp\mysql\bin\my.ini [mysqld] – Kin May 30 '17 at 12:52
-
Talha - You ROCK! You just saved me a massive 1.5 hour long headache. Thank you. – araisbec Jun 27 '19 at 19:56
-
1In my case I haven't deleted the user table, but after adding `skip-grant-tables` and browsing to Phpmyadmin it showed a notice saying that the user table is crashed and it needs repair. After running repair and removing `skip-grant-tables` and restarting server everything works as before. – Alexandru Trandafir Catalin Jul 02 '19 at 09:43
-
After following this solution I could not even start MySQL. XAMPP starts the process but could not assign the port – Vipul Hadiya Aug 31 '19 at 10:18
-
After trying all possible ways from [here](https://stackoverflow.com/questions/1276538/phpmyadmin-cant-connect-invalid-setings-ever-since-i-added-a-root-passwor) Neither worked, But this solution works fine. Thanks. But my question is after adding `skip-grant-tables` to `my.ini` file, There will be any problem again with `phpmyadmin` in the future? – Prasad Patel Nov 14 '19 at 11:06
-
Thank you so much. It helped me and saved some time!! – Gabriel Augusto Dec 01 '19 at 16:21