This method works for me. Use-cases for MySQL for me are:
- Connecting to it via Python
- Normal CRUD operations
I AM NO MYSQL EXPERT, BUT I WOULD RECOMMEND TO DO THIS ONLY ON YOUR LOCAL SYSTEM. DON'T DO THIS ON A SERVER. I'D NOT BE RESPONSIBLE FOR THE MESS YOU'VE CREATED.
- Install it
sudo apt install mysql-server
sudo service mysql start
- Run this command, it will open the MySQL shell.
sudo mysql
- This command will check the plugins used by various accounts.
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
Notice the following entry:
| root | | auth_socket | localhost |
You should be having this entry after a fresh install.
- Change the password (and use
caching_sha2_password
)
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'YOUR_PASS';
FLUSH PRIVILEGES;
- Done. check if we got it updated
| root | SOME_GARBAGE_HERE_THAT_SHOULDNT_BE_REVEALED | caching_sha2_password | localhost |
- Good. Now type
exit
and quit the mysql shell. - Try logging in again with
mysql -u root -p
- If the shell pops up, good job! You're lucky enough. You did it. If you didn't, surf StackOverflow, or Super User. There are many solutions.
If you feel anything is wrong here, let me know :)