-3

I want to update my MySQL password from I9O*Kez ---> SO123*

I perform these

mysql -u root -pI9O*Kez

service mysql stop 
mysqld_safe --skip-grant-tables &
mysql -uroot

use mysql; 
delete from user where User='root';

CREATE USER 'root'@'%' IDENTIFIED BY 'SO123*';
GRANT ALL PRIVILEGES ON * . * TO 'root'@'%';

I kept getting

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

Am I doing these completely wrong ?

It shouldn't be this difficult just to update a root password - right ?

code-8
  • 54,650
  • 106
  • 352
  • 604
  • Do I need to perform any of these ```service mysql stop mysqld_safe --skip-grant-tables & mysql -uroot ``` – code-8 Nov 07 '19 at 21:04
  • 1
    [so] is for programming questions. [dba.se] is the correct place to ask database administration questions. There are many questions there about changing the root password. – Barmar Nov 07 '19 at 21:04

1 Answers1

0

As the messages says, your server is currently running with the skip-grant-tables option enabled. This means your server is completely unprotected by any sort of credentials.

https://dev.mysql.com/doc/refman/8.0/en/server-options.html#option_mysqld_skip-grant-tables

As you've disabled grants entirely, you cannot issue a grant. Since you know the old root password, you don't need skip-grant-tables to change a password; stop doing that. It's only necessary if you need to reset a forgotten root password.

You also probably don't want to delete the user at all - MySQL can use ALTER USER to safely change a password.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • Can you please ... explain to me why would we need to do these `service mysql stop mysqld_safe --skip-grant-tables & mysql -uroot` ? Is it only when we forgot the root password, and need to reset it ? – code-8 Nov 07 '19 at 21:09
  • @kyo Running with `skip-grant-tables` means you can log in without a password, which is useful when you can't remember it. The rest are just basic "stop the service" and "log in to mysql with the root" user. You should **understand** the commands you're running before you go running them - it's very possible to irretrievably destroy data by blindly running commands from the Internet you don't understand. – ceejayoz Nov 07 '19 at 21:11