Showing posts with label Root. Show all posts
Showing posts with label Root. Show all posts

Thursday 9 May 2019

Access denied for user 'root'@'localhost' even password is correct

Error : SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket
Step 1 : For backup = cp -rfv /var/lib/mysql /var/lib/mysql$(date +%s)
Step 2 : sudo /etc/init.d/mysql stop
Step 3 : sudo mysqld_safe --skip-grant-tables & (If process will not complete after 5 minuts keep this window open and open another terminal window)
Step 4 :  mysql -u root -p 
Step 5 : FLUSH PRIVILEGES;
Step 6 : UPDATE user SET Grant_priv = 1, Super_priv = 1 WHERE user = 'root'
Step 7 : update user set password=PASSWORD("Franki3r0s3") where User='root';
Step 8 : GRANT ALL PRIVILEGES ON . TO 'root'@'localhost' IDENTIFIED BY 'anki8f0s3';

Additional commands : 
1. mysql# show users;
2. mysql# SELECT User FROM mysql.user;
3. ps -e | grep mysqld
4. kill -kill 16300
5. ps -x



Thursday 7 June 2018

How to reset MySQL / phpmyadmin root password on Ubuntu 18.04 Linux

1. The simplest approach to reset MySQL database root password is to execute mysql_secure_installation program and when prompted entering your new root MySQL password:
sudo mysql_secure_installation

New password:
Re-enter new password:
2. Let's stop the currently running MySQL database:
sudo service mysql stop
3. create a /var/run/mysqld directory to be used by MySQL process to store and access socket file:
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld 
4. Start manually MySQL with the following linux commands :
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
5. Confirm that the process is running as expected: 
jobs
6. Access MySQL database without password 
mysql -u root
7. First flush privileges MySQL session
mysql> FLUSH PRIVILEGES;
8. The following commands will reset MySQL root password to "root" 
mysql> USE mysql;
mysql> UPDATE user SET authentication_string=PASSWORD("root") WHERE User='root';
mysql> UPDATE user SET plugin="mysql_native_password" WHERE User='root';
9. Exit MySQL session: 
mysql> exit
10. Terminate current mysqld process 
sudo pkill mysqld
11. Start MYSQL database:
sudo service mysql start
12. If all went well you should now be able to login to your MySQL database with a root password: 
mysql -u root --password=root
mysql> exit