reset root (overarching) password for mysql


create a file called /var/lib/mysql/reset.txt file put the "alter user" statement inside it, like so:


echo "

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'abcd1234*;

 FLUSH PRIVILEGES;
" >
/var/lib/mysql/reset.txt


run


service mysql stop

mkdir -p /var/run/mysqld

chown mysql:mysql /var/run/mysqld

chmod 777 /var/run/mysqld # you can make this 755 some other time

mysqld --init-file=/var/lib/mysql/reset.txt  --user=mysql


Now do this to make it remember that you can login as root, this will let you just run “mysql” to run it. Security risk obviously.


user=`whoami`

su -c "mysql_config_editor set --host=localhost --user=root --password" -s /bin/bash “$user"


When it asks for a password, give your mysql password, e.g. abcd1234*

Comments

Popular posts from this blog

dump a specific table

completely erase and reinstall mysql script.

Tablespaces error