When you install MySQL and try to access it from your local machine as root, you may encounter this error
.
Run the command
mysql -u root -p
When prompted for a password, you press enter. The process suggests that a password for root has not yet been set. However, you should set the password because running as root without a password has many security concerns.
If the error persists, follow these commands:
mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root
mysql> use mysql;
mysql> select * from user;
mysql> flush privileges;
mysql> grant all privileges on *.* to root@localhost identified by 'Password' with grant option;
Enter your password in place of Password
.
mysql> quit
kill -KILL [PID of mysqld_safe]
kill -KILL [PID of mysqld]
service mysql start
mysql -u root -p password
Free Resources