Skip to content

Instantly share code, notes, and snippets.

@octavian-nita
Created October 24, 2014 08:54
Show Gist options
  • Select an option

  • Save octavian-nita/9dccf8cc192ab8a65780 to your computer and use it in GitHub Desktop.

Select an option

Save octavian-nita/9dccf8cc192ab8a65780 to your computer and use it in GitHub Desktop.
#!/bin/sh
sudo /etc/init.d/mysql stop
# OR
sudo /etc/init.d/mysqld stop
sudo mysqld_safe --skip-grant-tables
sudo mysql -u root << EOF
use mysql;
update user set password = PASSWORD("new-pwd") where user = 'root';
flush privileges;
quit;
EOF
sudo /etc/init.d/mysql restart
# OR
sudo /etc/init.d/mysqld restart
# TEST
sudo mysql -u -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment