What is the default root pasword for MySQL 5.7 What is the default root pasword for MySQL 5.7 linux linux

What is the default root pasword for MySQL 5.7


There's so many answers out there saying to reinstall mysql or use some combo of

mysqld_safe --skip-grant-tables

and / or

UPDATE mysql.user SET Password=PASSWORD('password')

and / or something else ...

... None of it was working for me


Here's what worked for me, on Ubuntu 18.04, from the top

With special credit to this answer for digging me out of the frustration on this ...

$ sudo apt install mysql-server$ sudo cat /etc/mysql/debian.cnf

Note the lines which read:

user     = debian-sys-maintpassword = blahblahblah

Then:

$ mysql -u debian-sys-maint -pEnter password: // type 'blahblahblah', ie. password from debian.cnfmysql> USE mysqlmysql> SELECT User, Host, plugin FROM mysql.user;+------------------+-----------+-----------------------+| User             | Host      | plugin                |+------------------+-----------+-----------------------+| root             | localhost | auth_socket           || mysql.session    | localhost | mysql_native_password || mysql.sys        | localhost | mysql_native_password || debian-sys-maint | localhost | mysql_native_password |+------------------+-----------+-----------------------+4 rows in set (0.00 sec)mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';mysql> COMMIT;  // When you don't have auto-commit switched on

Either:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

Or:

// For MySQL 5.7+UPDATE mysql.user SET authentication_string=PASSWORD('new_password') where user='root';

Then:

mysql> FLUSH PRIVILEGES;mysql> COMMIT;  // When you don't have auto-commit switched onmysql> EXIT$ sudo service mysql restart$ mysql -u root -pEnter password: // Yay! 'new_password' now works!


After you installed MySQL-community-server 5.7 from fresh on linux, you will need to find the temporary password from /var/log/mysqld.log to login as root.

  1. grep 'temporary password' /var/log/mysqld.log
  2. Run mysql_secure_installation to change new password

ref: http://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html


MySQL 5.7 changed the secure model: now MySQL root login requires a sudo

The simplest (and safest) solution will be create a new user and grant required privileges.

1. Connect to mysql

sudo mysql --user=root mysql

2. Create a user for phpMyAdmin

CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'some_pass';GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;FLUSH PRIVILEGES;

Reference - https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7