Posts

Showing posts with the label root password

How to reset MySQL 8 root password on CentOS 7 and 8

Occasionally you come up with the world's most unbreakable root password for a MySQL 8 installation and you get distracted before you record it somewhere.... and you remain distracted for 3 months. Then you return to the project where this database was needed and ... whoops! What was that totally awesome password? Here's how you can reset your root password. This was based on a page that had a similar instructions except none of them worked - lots of errors and incorrect names - like referring to mysql instead of mysqld when stopping the service. Here we go: All as root user: Create a file in /var/lib/mysql called mysql-pwd with the following contents: ALTER USER 'root'@'localhost' IDENTIFIED BY 'anotherPwd28^$94'; Shutdown mysql   systemctl stop mysqld Run MySQL executing the given init file under the mysql user   mysqld --init-file=/var/lib/mysql/mysql-pwd --user=mysql & Check the MySQL log to make sure no errors occurred:   vi /var/log/mysqld.log