Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. If you don't remember the MySql root user's password, you can use this tip:
  2.  
  3. root@server:~# mysql -u root -p
  4. Enter password:
  5. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
  6.  
  7. 1) Debian has an user for manteinance jobs on mysql, and the credentials are saved on a file:
  8.  
  9. root@server:~# cat /etc/mysql/debian.cnf
  10. # Automatically generated for Debian scripts. DO NOT TOUCH!
  11. [client]
  12. host = localhost
  13. user = debian-sys-maint
  14. password = xxxxxxxxxxxxxxxx
  15. socket = /var/run/mysqld/mysqld.sock
  16. [mysql_upgrade]
  17. host = localhost
  18. user = debian-sys-maint
  19. password = xxxxxxxxxxxxxxxx
  20. socket = /var/run/mysqld/mysqld.sock
  21. basedir = /usr
  22. root@server:~#
  23.  
  24. 2) Now access mysql with debian's user&pass and change the password for root user:
  25.  
  26. #>mysql -u debian-sys-maint -p
  27.  
  28. mysql> use mysql;
  29. mysql> UPDATE user SET password=PASSWORD('new_pass') WHERE user='root';
  30. Query OK, 1 rows affected (0.07 sec)
  31. Rows matched: 1 Changed: 1 Warnings: 0
  32.  
  33. mysql> exit
  34.  
  35. root@server:~# service mysql reload
  36. root@server:~# mysql -u root -pnew_pass
  37. Welcome to the MySQL monitor. Commands end with ; or \g.
  38. Your MySQL connection id is 8325
  39. Server version: 5.1.63-0+squeeze1 (Debian)
  40.  
  41. Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  42.  
  43. Oracle is a registered trademark of Oracle Corporation and/or its
  44. affiliates. Other names may be trademarks of their respective
  45. owners.
  46.  
  47. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  48.  
  49. mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement