Cannot login to MySQL database after fresh install with root ID and empty/no password like other older MySQL versions do
相关问题
- Is shmid returned by shmget() unique across proces
- How can I implement password recovery in an iPhone
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- how to get running process information in java?
None of these answers worked for me on Ubuntu Server 18.04.1 and MySQL 5.7.23. I spent a bunch of time trying and failing at setting the password and auth plugin manually, finding the password in logs (it's not there), etc.
The solution is actually super easy:
It's really important to do this with
sudo
. If you try without elevation, you'll be asked for the root password, which you obviously don't have.In case you want to install mysql or percona unattended (like in my case ansible), you can use following script:
Mysql generates a default temporary password as it is installed so to use mysql firstly you would be required to get that password from the log file which is present at the /var/log/mysqld.log. So follow the following process -
grep 'temporary password' /var/log/mysqld.log
mysql_secure_installation - This is required to change the password for mysql and also to make certain other changes like removing temporary databases , allow or disallow remote access to root user , delete Anonymous users etc.
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
2. Create a user for phpMyAdmin
Reference - https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7
I to was experiencing the same problem and the only thing I was able to do to make it work was to go this route:
drop user admin@localhost; flush privileges; create user admin@localhost identified by 'admins_password'
This allowed me to recreate my username and enter a password for the user name
There's so many answers out there saying to reinstall mysql or use some combo of
and / or
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 ...
Note the lines which read:
Then:
Either:
Or:
Then: