I have a root and test user which I don't remember the password for either one in mysql database. is it possible to create a new user from outside? I could not find answers for this in the internet. Thanks.
Asked
Active
Viewed 884 times
1
-
What do you mean 'outside'? Outside what? `mysql>` prompt? You will need to use privileged user to grant new privileges as well. – Alma Do Sep 05 '13 at 09:52
-
yeah, outside mysql prompt. if I don't have password for privileged user, is it not possible? – Spidey Sep 05 '13 at 10:22
-
If you have no other user with `GRANT` privilege - then no, you can't do that. But even if you have such user - you will need to operate with some mysql client (it could be pma, not native mysql shell, but in case of this question that's the same) – Alma Do Sep 05 '13 at 10:24
1 Answers
1
Restart mysqld with the --init-file
option specifying the path to a file that contains your desired commands. For example, to create a new superuser:
GRANT ALL ON *.*
TO 'new_user'@'localhost' IDENTIFIED BY 'new_password'
WITH GRANT OPTION;
Of course, you could also use this method to simply reset the passwords of the existing accounts:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new_password');

eggyal
- 122,705
- 18
- 212
- 237