Skip to content

Instantly share code, notes, and snippets.

@gmassawe
Created August 6, 2018 19:41
Show Gist options
  • Save gmassawe/f884389caf198cc01e1d97f1b10cf4c0 to your computer and use it in GitHub Desktop.
Save gmassawe/f884389caf198cc01e1d97f1b10cf4c0 to your computer and use it in GitHub Desktop.
change mySQL root password
Change MySQL root password on Ubuntu Server
============================================
~$ sudo service mysql stop
~$ sudo mysqld_safe --skip-grant-tables &
~$ sudo mysql -u root
> use mysql;
> update user set authentication_string=PASSWORD("New_Password") where User='root';
> flush privileges;
> exit;
~$ sudo service mysql stop
~$ sudo service mysql start
// check if it works
~$ sudo mysql -u root -p
// if you get this error "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'"
~$ sudo mkdir /var/run/mysqld/
~$ sudo chown mysql /var/run/mysqld/
// then go back to line 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment