First of all, I don't know why I can't log in to MySQL using the command line or workbench, and it prompts 'Access denied for user 'root'@'localhost'. Valid operation records: 1. First, skip the permissions to log in to MySQL and view the user table. Stop mysql service~ Start Notice: It may prompt mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exist Solution: (I tried and found that sudo must be added) sudo mkdir -p /var/run/mysqld sudo chown mysql:mysql /var/run/mysqld Execute the above safe mode again to start This time the prompt statement shows, This time you can log in without a password: mysql -u root Press Enter to log in The sql statement to query the mysql.user table is as follows: Add pictures (to be added later) Someone else suggested doing it this way, but I didn't try it.
2. Found that the user's plugin is socket_plugin, changed to mysql_native_password Modify the plugin permissions of root: update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root'; flush privileges; quit; (Note that the modification here must be correct, so as not to be like the author, carelessly modifying the content of the plugin by one letter less, and then having the following troubles) 3. There are other users in the user table. Root cannot log in, but you can log in with other users. After searching, I found the following valid operations: In the installation directory of mysql, there is usually a debain.cnf file in /etc/mysql, which contains user and password. Use this file to log in and copy the password. Then you can modify the plugin of the user table root again. The operation is the same as above. Restart the mysql service, You can log in as the root user. Reference blog: MySQL ERROR 1698 (28000) error https://www.jb51.net/article/117566.htm mysql How to view the currently used configuration file my.cnf https://www.jb51.net/article/110395.htm linux -- Ubuntu view and modify mysql login name and password, install phpmyadmin https://www.jb51.net/article/174925.htm Summarize The above is the editor's introduction to solving the MySQL login error: ''Access denied for user ''root''@''localhost''. I hope it will be helpful to everyone! You may also be interested in:
|
<<: JavaScript to implement the function of changing avatar
>>: How to turn a jar package into a docker container
Table of contents Install Pagoda Management Pagod...
Table of contents Introduction What does an itera...
Learning objectives: Learn to use Windows system ...
Thanks to the development of the Internet, we can...
Solution Abandon the Linux virtual machine that c...
1 Introduction After "Maven deploys Springbo...
Situation description: The database was started a...
1. Update the entire table. If the value of a col...
It is standard for websites to enable SSL nowaday...
The project was tested these days, and the tester...
In the nginx process model, tasks such as traffic...
Vue implements the palace grid rotation lottery (...
Visual Studio Code is a powerful text editor prod...
1. Add the viewport tag to the HTML header. At th...