How to restore MySQL root password even if you deleted the user

```bash sudo service mysql stop sudo mkdir /var/run/mysqld sudo chown mysql: /var/run/mysqld sudo mysqld_safe --skip-grant-tables --skip-networking & mysql -uroot mysql ``` If you deleted the root user you need to create it again: ```sql INSERT INTO `mysql`.`user` VALUES ('localhost','cccc','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'mysql_native_password' ,'','N','2018-06-05 06:39:28',NULL,'N'); ``` Now update the password: ```sql use mysql; update user set authentication_string=PASSWORD("") where User='root'; update user set plugin="mysql_native_password"; flush privileges; quit; ``` ```bash sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown sudo service mysql start ```