Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- To begin, stop the database service and check the service status:
- ------------- SystemD -------------
- # systemctl stop mariadb
- ------------- SysVinit -------------
- # /etc/init.d/mysqld stop
- Next, start the service with --skip-grant-tables:
- ------------- SystemD -------------
- # systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
- # systemctl start mariadb
- # systemctl status mariadb
- ------------- SysVinit -------------
- # mysqld_safe --skip-grant-tables &
- This will allow you to connect to the database server as root without a password (you may need to switch to a different terminal to do so):
- # mysql -u root
- From then on, follow the steps outlined below.
- MariaDB [(none)]> USE mysql;
- MariaDB [(none)]> UPDATE user SET password=PASSWORD('YourNewPasswordHere') WHERE User='root' AND Host = 'localhost';
- MariaDB [(none)]> FLUSH PRIVILEGES;
- Finally, stop the service, unset the environment variable and start the service once again:
- ------------- SystemD -------------
- # systemctl stop mariadb
- # systemctl unset-environment MYSQLD_OPTS
- # systemctl start mariadb
- ------------- SysVinit -------------
- # /etc/init.d/mysql stop
- # /etc/init.d/mysql start
- This will cause the previous changes to take effect, allowing you to connect to the database server using the new password.
Add Comment
Please, Sign In to add comment