Glam Prestige Journal

Bright entertainment trends with youth appeal.

How to reset or delete or enter new password or see the password. If still unable to resolve, how to delete all MySQL dependency and reinstall fresh. I am new to Linux and this is my personal computer (laptop). Please see the output of my terminal.

pra@pra-K55N:~$ sudo mysql
[sudo] password for pra:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
pra@pra-K55N:~$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:
Error: Access denied for user 'root'@'localhost' (using password: YES)
pra@pra-K55N:~$ sudo service mysql stop
pra@pra-K55N:~$ sudo mysqld_safe --skip-grant-tables &
[1] 2466
pra@pra-K55N:~$ 2019-11-15T14:56:08.897357Z mysqld_safe Logging to syslog.
2019-11-15T14:56:08.907624Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2019-11-15T14:56:08.915473Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
[1]+ Exit 1 sudo mysqld_safe --skip-grant-tables
pra@pra-K55N:~$ sudo mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
pra@pra-K55N:~$ sudo service mysql start
pra@pra-K55N:~$ sudo mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
pra@pra-K55N:~$ 

please see mysql.cnf

!includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/

2

1 Answer

i suggest steps to reset root password by running the server with option --skip-grant-tables this option allow you to log in in mysql without password running this with sudo:

# sudo service mysql stop

# sudo mysqld_safe --skip-grant-tables &

# sudo mysql -u root

mysql> use mysql;

mysql> update user set authentication_string=PASSWORD("YOUR-NEW-ROOT-PASSWORD") where User='root';

mysql> flush privileges;

mysql> quit

# sudo service mysql stop

# sudo service mysql start

# sudo mysql -u root -p

Now you can login to sql with your new password

check may be it's possible to find a query file about root password in path /home/$USER/.mysql_history or /root/.mysql_history

Note: prior to MySQL 5.7 the column was called password instead of authentication_string. Replace the line above with

mysql> update user set password=PASSWORD("YOUR-NEW-ROOT-PASSWORD") where User='root';

Goodluck

6