Ubuntu – MySQL how to log into “root” from a user account after upgade to 5.7

14.04MySQLserver

Running Ubuntu Server 14.04, installed MySQL 5.7 using the MySQL APT Repository. I cannot access MySQL using the "root" user from a user account ($) but I can with sudo or sudo su - (#). The MySQL "root" user is working, of course – I can log in as root (#) with my password.

All MySQL configuration other than the custom "root" password is defaults. The "root" password is updated as # echo "ALTER USER 'root'@'localhost' IDENTIFIED BY '$MYSQLPASS'" | mysql.

Both the above command and installing MySQL are done automatically as provisioning steps, if that influences the defaults at all. I was able to log in to MySQL from $ using "root" prior to the upgrade, but I'm not seeing any MySQL specific changes related to this.

How can I log into MySQL's as "root" from a user account again?

Best Answer

  • stop mysql server (service mysql stop or ps aux | grep mysql to determine the PID and then kill -9 PID)
  • mysqld_safe --skip-grant-tables
  • UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root' to fix the root PW not working
  • update mysql.user set authentication_string=password('YOURNEWPASSWORD') where user='root';
  • killall -9 mysqld_safe
  • service mysql start