-1

I enter mysql -u root -p and put in my password and get this error, I have uninstalled and reinstalled mysql and changing the password for root but still get this message.

I have looked and looked for solutions but nothing seems to work.

I am trying to enter mysql through my terminal, instead I get get the error above and can't get into mysql even after uninstalling and reinstalling it.

Laker1989
  • 1
  • 1
  • 1

2 Answers2

0

Usually this means that you are using the wrong credentials to connect, try to consult consult the general log file /var/log/mysqld.log to copy the initialization password.

if that doesn't work you can try this approach:

  1. check if MySQL is installed and running on your system sudo service mysql status

  2. Reset the root password:

  • stop the server: sudo /etc/init.d/mysql stop
  • start the server in safe mode: sudo mysqld_safe --skip-grant-tables &
  • try to connect: mysql -u root
  • reset the root password: UPDATE mysql.user SET authentication_string=PASSWORD('newpassword'), password_expired='N' WHERE User='root';
  • flush privileges: FLUSH PRIVILEGES;
  • quit the server: quit
  • stop the safe mode server: sudo /etc/init.d/mysql stop
  1. now you can start the MySQL server again: sudo /etc/init.d/mysql start

  2. Use the correct credentials to connect (with the new password)

check out previous answers to this problem here and here.

Lemonina
  • 712
  • 2
  • 14
0

This is what worked for me:

  1. Type sudo mysql
  2. Type current_user(); to see the current user data.
  3. Use ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';. Replace 'root'@'localhost' with the data that was retrieved from current_user(); and new_password with your desired password. Don't forget the single quotations.
Esraa Abdelmaksoud
  • 1,307
  • 12
  • 25