In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you what to do when there is a 1045 error in MySQL login in centos. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Due to the need to deploy the entire application under centos, it is natural to operate on the database. However, many people may encounter some problems, such as creating a user successfully but unable to log in.
There are usually two reasons why you can't log in. First, the remote access port is not open, and the second reason is that the password is wrong (strangely, the password when we log in is obviously correct, but it will still prompt the wrong password. I don't know why, maybe it's a code or something).
It is easy to solve the situation that the remote access port is not open. If you use a CVM, configure the security group in the console and open the corresponding port.
Let's talk about the second mistake here, which is rather sinister.
In the second case, an error is often reported: 1045 Access denied for user 'root'@'%' (using password:YES).
I'll outline the whole process. My operating system is centos7.4,MySQL version 5.7.
First of all, log in to mysql, mine is root users. The login command is
Mysql-u root-p
After entering the login password, the window changes as shown below:
First of all, let's take a look at the current users in the system, as well as their specific permissions and specific commands:
View users:
SELECT DISTINCT CONCAT ('User:'', user,'''@''',host,''';') AS query FROM mysql.user
View the permissions of a specific user:
Show grants for 'root'@'%'
The window changes as shown below:
Next I'm going to create a user so that the changed user can access the database remotely and operate on it. The specific commands are as follows:
Create user zhangsanidentified by 'zhangsan.CQU.2020.lisi';grant all privileges on *. * to zhangsan@'%' identified by' zhangsan.CQU.2020.lisi'
Or a single order to do it:
Grant all privileges on *. * to 'zhangsan'@'%' identified by' zhangsan.CQU.2020.lisi' with grant option
After the operation is completed, be sure to refresh it, otherwise it may not take effect, such as
Flush privileges
If you look at the user at this point, you can see that there is one more user, that is, the user we just created.
Type exit, exit MySQL, and then try to log in with the zhangsan account.
The problem appeared smoothly, but I couldn't get on it, so let's go to solve it.
First of all, find your own my.cnf file for MySQL. (mine is under the etc folder. Different people may be different. Use the Linux command to find it according to the conditions.)
After opening the file (vi my.cnf), enter edit mode (a) find the mysqld keyword, add skip-grant-tables under mysqld, and save and exit (first esc, then: wq), as shown in the figure:
Just remove the comments.
Then restart mysql with the following command:
Service mysqld restart
The next step is to log in again and change the password.
Prompt to enter the password there, directly enter, skip password verification, login is successful. Next, go to the mysql database and change the password. The command is as follows.
Use mysql
Change the password:
Update user set authentication_string=password ("zhangsan.CQU.2020.lisi") where user= "zhangsan"
As shown in the figure:
Then exit mysql, change back the my.cnf file that you just modified, and restart mysql.
You can see that the login is successful and the remote connection is successful, so there is no demonstration. If the remote login is not successful, check the port settings to see if remote access is enabled.
Thank you for reading! This is the end of the article on "what to do when there are 1045 errors in MySQL login in centos". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 205
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.