'MySQL shell error while attempting to connect

I want to configure a MySQL server for a wordpress.org project on Windows. However, I can't seem to connect to the MySQL server via MySQL shell.

when I inputted the command \connect root@localhost, and entered the password, I got an error:

MySQL Error 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

I assumed that I had forgot my password, and tried saving a txt file with the command ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

Yet I got the same error message. I then reset the password with mysqld --skip -grant, and when I restarted MySQL and tried to use \connect, I got the error

MySQL Error 1045: Access denied for user 'root'@'localhost' (using password: NO)

I also tried mysql -u root -p, but got the error

ERROR: Not connected.

Basically everything that didn't start with \ generated a Not Connected error.

I tried using the Command Prompt instead of the MySQL shell, but got the exact same error. How can I properly access MySQL?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source