当前位置:网站首页>Login error in mysql: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)ERROR

Login error in mysql: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)ERROR

2022-08-11 06:56:00 happy hiding in the eyebrows

This is a one-click deployment of the execution scriptMySQL 8.0The error message that appears when :一键安装8.0版本脚本文件

如果在登录MySQLThis error message appears:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO).

Both errors belong to the same category,i.e. wrong password.

解决思路:Password-free login to change password,Use the modified password again.

1、首先先关闭mysql.

service mysqld stop

2、查看mysql的状态

service mysqld status

3、Sets the use of commands to skip the process of entering passwords

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

4、另开一个窗口--登录MySQL---不要输入密码,直接回车.

mysqld -uroot -p

5、使用一下MySQL数据库--指定数据库

use mysqld;

6、查看mysql数据库中user表,用户等于root的用户,Just show it

select 'user' from user where user='root';

7、为user=rootThe user sets the password to 123456

update user set password=PASSWORD('123456') where user='root';

8、刷新使之生效,并退出.

flush privileges;

exit;

9.重启mysqld

service mysqld restart

10、查看mysql状态

service mysqld status

11、正常登录

mysql -u root -p 123456

There may be a problem with this script:1.密码过于简单,MySQLSetting too simple passwords may not be allowed.

注意:update user set password=PASSWORD('123456') where user='root';An error will be reported when executing this statement.

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '('12346') where user='root'' at line 1

报错的原因是MySQL8.0版本取消了password函数进行加密.Because the statement to change the password in the above script reports an error,So we replaced a change password statement,如下:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'hxpatroldelay_mysqldb';

This statement will also throw an error,错误如下:

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement.

That is because we are in password-free login mode,You can only query and change the password,不能进行alert操作.经过n次尝试后,We learned about initializationMySQLThe data directory can be regenerated with a temporary password,话不多说,看操作

第一次初始化,直接开始初始化.

[[email protected]_hq_shszwc_204_150 ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/hqdata/mysql

You have new mail in /var/spool/mail/root

 日志报错:

2022-06-23T06:29:40.071157Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.

2022-06-23T06:29:40.071249Z 0 [ERROR] [MY-013236] [Server] The designated data directory /hqdata/mysql/ is unusable. You can remove all files that the server added to it.

2022-06-23T06:29:40.071477Z 0 [ERROR] [MY-010119] [Server] Aborting

原因:The data directory must be cleared manually before initialization,If the data directory is not emptymysqldThe service cannot regenerate new data. lead to a subsequent restartmysqld服务失败,Because it is not deleted before initializationmysql的数据目录.

[[email protected]_hq_shszwc_204_150 ~]#

[[email protected]_hq_shszwc_204_150 ~]# service mysqld restart

MySQL server PID file could not be found! [ʧ▒▒]

Starting MySQL...................The server quit without up[ʧ▒▒]g PID file (/hqdata/mysql/nw_hq_shszwc_204_150.pid).

日志报错:2022-06-23T06:36:37.837501Z 0 [ERROR] [MY-011292] [Server] Plugin mysqlx reported: 'Preparation of I/O interfaces failed, X Protocol won't be accessible'

2022-06-23T06:36:37.838064Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of bind-address: '*' port: 33060 failed, `bind()` failed with error: Address already in use (98). Do you already have another mysqld server running with Mysqlx ?'

2022-06-23T06:36:37.838773Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/tmp/mysqlx.sock' failed, another process with PID 18968 is using UNIX socket file'

2022-06-23T06:36:39.338736Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.

2022-06-23T06:36:39.341413Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use

2022-06-23T06:36:39.341702Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3306 ?

2022-06-23T06:36:39.342523Z 0 [ERROR] [MY-010119] [Server] Aborting

 因为mysqld服务无法关闭,The resulting restart failed.初始化之后,Temporary passwords are generated in the log file.After logging in with a temporary password,即可使用alert语句更改密码:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '[email protected]';
Query OK, 0 rows affected (0.09 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
原网站

版权声明
本文为[happy hiding in the eyebrows]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/223/202208110516510682.html