博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql 1045 28000_mysql报关于用户密码1045(28000),几种处理方法 (zhuan)
阅读量:1540 次
发布时间:2019-04-21

本文共 3687 字,大约阅读时间需要 12 分钟。

--mysql5.6,安装好后进行登录出现

[root@mytest_db usr]# mysql -uroot -p

Enter password:

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

提示密码问题,再用命令修改,也会出现以下错误

[root@mytest_db usr]# mysqladmin -u root password 'petrel'

mysqladmin: connect to server at 'localhost' failed

error: 'Access denied for user 'root'@'localhost' (using password: NO)'

这个时候需要用这种方法进行处理

--重启mysql服务,采用mysqld_safe的方式进行

[root@mytest_db usr]# service mysql stop

Shutting down MySQL...[  OK  ]

[root@mytest_db usr]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[1] 5043

启动后,就可以直接不用密码直接进入了,这个时候重新设置密码

[root@mytest_db usr]# mysql -uroot

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set Password=PASSWORD('petrel') where user = 'root';

Query OK, 4 rows affected (0.00 sec)

Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

mysql> quit

Bye

[root@mytest_db usr]# service mysql restart

这个时候,再进行登录就没问题了

[root@mytest_db data]# mysql -uroot -ppetrel

Warning: Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 4

Server version: 5.6.19

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

登录后,需要再进行一次密码设置才能使用。

mysql> use mysql;

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> grant all privileges  on *.* to root@'localhost'   identified   by 'petrel';

ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

mysql> set PASSWORD=PASSWORD('petrel');

Query OK, 0 rows affected (0.00 sec)

--出现mysql.user表里面用户为空时出现

ERROR 1045 (28000): Access denied for user

这个时候可以进行如下处理

删除这些为空的用户或者更新为其他用户名

删除user.user中值为NULL的,或更新NULL为其它值等

mysql> delete from user where user is NULL

Query OK, 1 rows affected (0.00 sec)

或者更新为其它值

mysql> update user set user='mytest' where user is NULL

Query OK, 1 rows affected (0.00 sec)

--如果mysql.user表里面没有可以访问的用户,也会出现

MYSQL ERROR 1045 (28000): Access denied for user (using password: YES)

这个时候,我们就要采用如下步骤进行

[root@mytest_db usr]# service mysql stop

Shutting down MySQL...[  OK  ]

[root@mytest_db usr]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[root@mytest_db usr]# mysql -uroot

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> select * from user;

发现没有用户

mysql> INSERT INTO user(host, user, password, select_priv,

insert_priv, update_priv) VALUES ('localhost', 'username',

PASSWORD(‘yourpassword'), 'Y', 'Y','Y');

Query OK, 1 row affected, 3 warnings (0.00 sec)

转载地址:http://aoldy.baihongyu.com/

你可能感兴趣的文章
硬件工程师太难了
查看>>
正在消失的MCU与MPU之间的界限
查看>>
IMU中加速度计、陀螺仪、磁力计的工作原理
查看>>
PCB上三防漆规范和注意事项
查看>>
进程和线程常见的19个问题
查看>>
Keil MDK 和 IAR EARM发展历程及历史版本下载
查看>>
精选汇总 | 嵌入式软件基础知识
查看>>
为什么大家都看好RISC-V
查看>>
Keil MDK利用 fromelf 实现axf 转 bin 的方法
查看>>
2.10. Wi-Fi
查看>>
Golang Ruby ASP PowerShell
查看>>
6.1. 信息收集 - Windows
查看>>
日常运维管理技巧十三(chkconfig使用说明)
查看>>
日常运维管理技巧十四(rsync使用说明)
查看>>
日常运维管理技巧十五(linux系统日志)
查看>>
日常运维管理技巧十六(screen工具)【完】
查看>>
LAMP架构一(介绍)
查看>>
LAMP架构二(Mariadb数据库安装)
查看>>
LAMP架构三(Apache的安装)
查看>>
LAMP架构四(PHP5.6的安装)
查看>>