I have tried every fix that I have found, and I cannot change my root MySQL password. At the shell, if I type in mysql -u root
, I get
Access denied for user 'root'@'localhost' (using password: NO)
When I go to PHP MyAdmin, I get this:
#1045 - Access denied for user 'root'@'localhost' (using password: YES)
This all started when I was forced to enter a new password for MySQL. I have NO idea how to fix this and I am desperate.
Thank you.
On Ubuntu systems, the default location for the MySQL is /var/log/mysql/error. log . In many cases, the error logs are most easily read with the less program, a command line utility that allows you to view files but not edit them: sudo less /var/log/mysql/error.
normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.
The ERROR 1064 (42000) mainly occurs when the syntax isn't set correctly i.e. error in applying the backtick symbol or while creating a database without them can also create an error, if you will use hyphen in the name, for example, Demo-Table will result in ERROR 1064 (42000).
my problem was solved in below way.
When I was entered below command then I will get an error. sudo mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).
To resolve this follow below steps. Enter command,
sudo mysqld_safe --skip-grant-tables &
Then the below error occurred.
2018-12-17T06:43:33.106111Z mysqld_safe Logging to syslog.
2018-12-17T06:43:33.108971Z mysqld_safe Logging to '/var/log/mysql/error.log'.
/usr/bin/mysqld_safe: 152: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
2018-12-17T06:43:33.111388Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
/usr/bin/mysqld_safe: 152: /usr/bin/mysqld_safe: cannot create /var/log/mysql/error.log: Permission denied
To resolve this error, then follow below lines.
systemctl stop mysql
2018-12-17T06:48:42.971692Z mysqld_safe Logging to syslog.
2018-12-17T06:48:42.974451Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2018-12-17T06:48:42.976653Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo mysqld_safe --skip-grant-tables &
2018-12-17T06:50:39.135292Z mysqld_safe Logging to syslog.
2018-12-17T06:50:39.137938Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2018-12-17T06:50:39.152966Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Then connect mysql -u root
. then MySQL prompt will appear. then after set your password.
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
systemctl stop mysql
After that loing in below way. mysql -u root -p
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With