While Resetting the Database Password of VPS this message shows when running command. While restarting the database server you need to run this command
sudo mysqld_safe –skip-grant-tables –skip-networking &
here The ampersand(&) at the end of this command will make this process run in the background so you can continue to use your terminal.
For me when I run this command it shows “mysqld_safe Directory ‘/var/run/mysqld’ for UNIX socket file don’t exists”. In that case you just need to run those command and the “mysqld” directory will automatically create.
mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld
Now you can connect to the database as the root user, which will not asked for a password. Now use this Command:
mysql -u root
Now this MySQL Prompt Will Promt
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement
For MariaDB
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
MariaDB [(none)]>
Now that you have root access, you can change the root password.