Skip to content

Instantly share code, notes, and snippets.

@nicolasramy
Last active August 10, 2021 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolasramy/95941b09260bf7f2b2cdbb705c3ba85b to your computer and use it in GitHub Desktop.
Save nicolasramy/95941b09260bf7f2b2cdbb705c3ba85b to your computer and use it in GitHub Desktop.
MySQL Tips

Remove

To remove everything related to MySQL, you have to follow this procedure

sudo -i
service mysql stop
killall -KILL mysql mysqld_safe mysqld
apt-get --yes purge mysql-server mysql-client
apt-get --yes autoremove --purge
apt-get autoclean
deluser --remove-home mysql
delgroup mysql
rm -rf /etc/apparmor.d/abstractions/mysql /etc/apparmor.d/cache/usr.sbin.mysqld /etc/mysql /var/lib/mysql   /var/log/mysql* /var/log/upstart/mysql.log* /var/run/mysqld
updatedb
exit

Change root password

Stop MySQL Server

service mysql stop

Start Mysql uin safe mode without Grant Privileges

mysqld_safe --skip-grant-tables

For MySQL 5.7.6+

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

For MySQL 5.7.5 and lesser

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment