I locked my root user out from our database. I need to get all privileges back to the root user. I have my password and I can log in to MySQL. But the root user has no all privileges.
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
I had the same problem as the title of this question, so incase anyone else googles upon this question and wants to start MySql in 'skip-grant-tables' mode on Windows, here is what I did.
Stop the MySQL service through Administrator tools, Services.
Modify the my.ini configuration file (assuming default paths)
or for MySQL version >= 5.6
In the SERVER SECTION, under [mysqld], add the following line:
so that you have
Start the service again and you should be able to log into your database without a password.
Use the following command (notice the "d"):
mysqld --skip-grant-tables
How to re-take control of the root user in MySQL.
DANGER: RISKY OPERATTION
Edit
my.cnf
file using.Add line to mysqld block.*
Save and exit.
Restart MySQL service.
Check service status.
Connect to mysql.
Using main database.
Redefine user root password.
Edit file my.cnf.
Erase line.
Save and exit.
Restart MySQL service.
Check service status.
Connect to database.
Type new password when prompted.
This action is very dangerous, it allows anyone to connect to all databases with no restriction without a user and password. It must be used carefully and must be reverted quickly to avoid risks.
After trying lots of things, this is what worked for me:
So first we use sudo to log in mysql as root without needing a password. Then we just update root's password.
After that, I restarted
mysqld
:And the
newpassword
logged root in!