Skip to content

Instantly share code, notes, and snippets.

@freretuc
Created January 10, 2015 09:06
Show Gist options
  • Save freretuc/a48761a5d387b023d2ee to your computer and use it in GitHub Desktop.
Save freretuc/a48761a5d387b023d2ee to your computer and use it in GitHub Desktop.
Unix : lost mysql root password
/etc/init.d/mysql stop
echo "UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES;" >> /home/mysql-init
mysqld_safe --init-file=/home/mysql-init &
rm /home/mysql-init
/etc/init.d/mysql stop
/etc/init.d/mysql start
or
/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
(in mysql shell)
mysql> use mysql;
mysql> update user set password=PASSWORD("MyNewPass") where User='root';
mysql> flush privileges;
mysql> quit
/etc/init.d/mysql stop
/etc/init.d/mysql start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment