Tuesday, May 7, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  44] [ 0]  / answers: 1 / hits: 79272  / 1 Year ago, thu, march 16, 2023, 8:48:02

I need to reset the root password of my local mysql installation but it woudln't let me. I've tried this:



$ sudo /etc/init.d/mysql stop
* Stopping MySQL database server mysqld [ OK ]
[1]- Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
[2]+ Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking
reg@regDesktopHome:~$ sudo mysqld --skip-grant-tables &
[1] 13651
reg@regDesktopHome:~$ 140627 19:02:02 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.

reg@regDesktopHome:~$ mysql -u root mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
reg@regDesktopHome:~$ sudo mysql -u root mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[1]+ Exit 1 sudo mysqld --skip-grant-tables


How can I get the password reset?
edit 1
I got this:



$ ps ax| grep mysql
16515 ? Ssl 0:00 /usr/sbin/mysqld
16551 pts/23 S+ 0:00 grep --color=auto mysql
reg@regDesktopHome:~/semios/v3upgrade$ sudo kill -9 16515
reg@regDesktopHome:~/semios/v3upgrade$ ps ax| grep mysql
16678 ? Ssl 0:00 /usr/sbin/mysqld
16715 pts/23 S+ 0:00 grep --color=auto mysql
reg@regDesktopHome:~/semios/v3upgrade$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


looks like a process is automatically restarting mysql as soon as I kill it...


More From » password

 Answers
6

First please try using



mysql -u root -p


and enter your password (if you remember) at the prompt to login as the sql-root user (note the switch -p is for password).



If you really have to reset your root password for mysql, here's an easy way - reconfigure the package with dpkg-reconfigure.



Easy steps to reset mySQL root password:




  1. Check the version of your mysql-server;



    apt-cache policy mysql-server


    and see for the line which shows the installed version among other information. e.g. for my install it's:



    Installed: 5.5.37-0ubuntu0.12.04.1


    (From this I know that I have mysql-server-5.5 installed in my system.)


  2. Start the reconfiguration with:



    sudo dpkg-reconfigure mysql-server-*.*


    where mysql-server-*.* should be replaced by the version that you have. (for me it'd be mysql-server-5.5). This will stop the database daemon. A prompt will then appear where you'd have to enter your new password and confirm the reconfiguration.



    snap1



    The daemon will be automatically started after the reconfig completes.


  3. You can then log in with:



    mysql -u root -p


    and start your database admin tasks.




References:




  1. https://help.ubuntu.com/community/MysqlPasswordReset [Which would soon be cleaned up as indicated in the page.]


  2. Ubuntu Server Guide related to your specific version.



[#24394] Friday, March 17, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rmodmi

Total Points: 390
Total Questions: 122
Total Answers: 111

Location: Venezuela
Member since Mon, Oct 18, 2021
3 Years ago
;