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
On the Linux system you can do following (Should be similar for other OS)
Check if mysql process is running:
If runnning then stop the process: (Make sure you close all mysql tool)
If you have issue stopping then do following
Search for process:
ps aux | grep mysqld
Kill the process:kill -9 process_id
Now start mysql in safe mode with skip grant
if you are running on
Apple MacBook OSX
then:my.cnf
. (For me it was placed @/Applications/XAMPP/xamppfiles/etc
. You can just search if you can't find it).my.cnf
file in any text editor."skip-grant-tables"
(without quotes) at the end of[mysqld]
section and save the file.skip-grant-tables
option.Do what you want now!!
PS: Please remove
skip-grant-tables
frommy.cnf
file once you are done with whatsoever you want to do ELSE MySQL server will always run without access grants.if this is a windows box, the simplest thing to do is to stop the servers, add skip-grant-tables to the mysql configuration file, and restart the server.
once you've fixed your permission problems, repeat the above but remove the skip-grant-tables option.
if you don't know where your configuration file is, then log in to mysql send
SHOW VARIABLES LIKE '%config%'
and one of the rows returned will tell you where your configuration file is.Edit my.ini file and add skip-grant-tables and restart your mysql server :
I'm in windows 10, using WAMP64 server. Searched for
my.cnf
andmy.ini
. Foundmy.ini
inC:\wamp64\bin\mariadb\mariadb10.2.14
.Following the instructions from the colleagues:
my.ini
in a text editor, searched for[mysqld]
'skip-grant-tables'
at the end of the[mysqld]
section (but within it)skip-grant-tables
optionALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassword';
my.ini
file, erase the'skip-grant-tables'
line, save the fileNow you can enter with the new password. Thanks to all answers here.
If you use mysql 5.6 server and have problems with
C:\Program Files\MySQL\MySQL Server 5.6\my.ini
:You should go to
C:\ProgramData\MySQL\MySQL Server 5.6\my.ini
.You should add
skip-grant-tables
and then you do not need a password.Note: after you are done with your work on
skip-grant-tables
, you should restore your file ofC:\ProgramData\MySQL\MySQL Server 5.6\my.ini
.