Guest User

Untitled

a guest
Dec 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. To begin, stop the database service and check the service status:
  2.  
  3. ------------- SystemD -------------
  4. # systemctl stop mariadb
  5. ------------- SysVinit -------------
  6. # /etc/init.d/mysqld stop
  7.  
  8. Next, start the service with --skip-grant-tables:
  9.  
  10. ------------- SystemD -------------
  11. # systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
  12. # systemctl start mariadb
  13. # systemctl status mariadb
  14. ------------- SysVinit -------------
  15. # mysqld_safe --skip-grant-tables &
  16.  
  17. 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):
  18.  
  19. # mysql -u root
  20.  
  21. From then on, follow the steps outlined below.
  22.  
  23. MariaDB [(none)]> USE mysql;
  24. MariaDB [(none)]> UPDATE user SET password=PASSWORD('YourNewPasswordHere') WHERE User='root' AND Host = 'localhost';
  25. MariaDB [(none)]> FLUSH PRIVILEGES;
  26.  
  27. Finally, stop the service, unset the environment variable and start the service once again:
  28.  
  29. ------------- SystemD -------------
  30. # systemctl stop mariadb
  31. # systemctl unset-environment MYSQLD_OPTS
  32. # systemctl start mariadb
  33. ------------- SysVinit -------------
  34. # /etc/init.d/mysql stop
  35. # /etc/init.d/mysql start
  36.  
  37. 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