mysql 安装完成后登陆不了mysql的 shell 即mysql>遇到:ERROR 1045 (28000): Access denied for user 'root'@'localhost‘

[[email protected] ~]# mysql

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

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

网上找了很多的文章还是没有解决我的问题;

1.首先可以确认的是mysql 命令行 sql命令关键字是不区分大小写;在5.1.51版本;

2.先将正常启动的mysqld stop掉;

3.再以绕过root口令检查的方式 start mysqld;

以下是解决经过:

1.先将正常启动的mysqld stop掉

[[email protected] ~]# service mysqld stop

Stopping mysqld:                                           [  OK  ]

2.用绕过root口令检查的方式 启动 mysql 服务器,并且让其在后头运行;

[[email protected] ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[1] 25513

[[email protected] ~]# 141215 15:00:16 mysqld_safe Logging to ‘/var/log/mysqld.log‘.

141215 15:00:16 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

3. mysql回车,进入mysql shell,按照前人留下的方法, update user表中的 root 用户的密码,结果发现 0 rows affected,再select 细看是 user 表是空的;

[[email protected] ~]# mysql

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

Your MySQL connection id is 1

Server version: 5.1.51 Source distribution

mysql> UPDATE user SET PASSWORD=PASSWORD(‘123456‘) where USER=‘root‘;

Query OK, 0 rows affected (0.00 sec)

Rows matched: 0  Changed: 0  Warnings: 0

mysql>  use mysql

Database changed

mysql> show tables;

+---------------------------+

| Tables_in_mysql           |

+---------------------------+

| columns_priv              |

| db                        |

| event                     |

| func                      |

| general_log               |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| host                      |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| servers                   |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

+---------------------------+

23 rows in set (0.00 sec)

mysql> select * from user;

Empty set (0.00 sec)

4.在user表 insert 一个名称为root的用户;

mysql> insert into user(Host,User,Password,Select_priv,Insert_priv) VALUES(‘localhost‘,‘root‘,PASSWORD(‘pass3‘),‘Y‘,‘Y‘);

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

5.#看到有个root用户了;

mysql> select * from user

-> ;

+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+

| Host      | User | Password                                  | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv
| Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | ssl_type
| ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections |

+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+

| localhost | root | *35B5E90BC4F5AE5D02ED515DF6B61141F24EDA02 | Y           | Y           | N           | N           | N           | N         | N           | N             | N            | N         | N          | N               | N          | N         
| N            | N          | N                     | N                | N            | N               | N                | N                | N              | N                   | N                  | N                | N          | N            |         
|            |             |              |             0 |           0 |               0 |                    0 |

+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+

1 row in set (0.00 sec)

6 再更新 root 用户的密码,也能返回成功了;

mysql> UPDATE user SET Password = PASSWORD(‘newpass‘) WHERE user = ‘root‘;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

7.stop 刚才的 mysql服务,以正常方式重新启动mysql 服务器,mysql -u root -p  密码是newpass

[[email protected] ~]# service mysqld stop

141215 16:12:24 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Stopping mysqld:                                           [  OK  ]

[1]+  Done                    mysqld_safe --user=mysql --skip-grant-tables --skip-networking

[[email protected] ~]# service mysqld start

Starting mysqld:                                           [  OK  ]

[[email protected] ~]#

[[email protected] ~]# mysql

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

[[email protected] ~]# mysql -u root -p

Enter password:

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

Your MySQL connection id is 4

Server version: 5.1.51 Source distribution

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

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

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

mysql>

mysql 安装完成后登陆不了mysql的 shell 即mysql>遇到:ERROR 1045 (28000): Access denied for user 'root'@'localhost‘

时间: 2024-07-30 09:25:20

mysql 安装完成后登陆不了mysql的 shell 即mysql>遇到:ERROR 1045 (28000): Access denied for user 'root'@'localhost‘的相关文章

mac系统中搭建apache+mysql+php的开发环境,安装mysql后,登录报错:mac ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

php新手在mac系统中搭建apache+mysql+php的开发环境(按照这篇博客来操作的:http://my.oschina.net/joanfen/blog/171109?fromerr=xvCsafCe),在安装配置mysql完毕后,登录mysql,报错:mac ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO),折腾很久,终于解决,随手记录下,备忘. 解决方法: 第一步:如

mysql登陆提示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO

今天安装zabbix,安装完成之后在最上面提示如下所示 检查日志如下显示 显示连接数据库失败,登录mysql给zabbix授权之后发现zabbix彻底起不来了 数据库也登陆不进去,提示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 数据库拒绝了root登录,于是先跳过受权表访问,命令如下:mysqld_safe --user=mysql --skip-grant-tables -

Mysql 命令行启动问题ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Centos 刚装了mysql yum install mysql 安装成功了,安装最后要求输入了密码,也输入了,OK mysql -uroot -p 输入设置的密码 竟然报错了! ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YSE) 问朋友,他说初始密码是空的,可我命名设置了密码的阿. 密码留空 还是错误! ERROR 1045 (28000): Access denied for

MySQL出现 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决办法

进入cmd 输入 mysql -u root -p 出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 找到安装mysql的根目录打开 my.ini文件 添加一条语句 skip-grant-tables 保存后退出 进入cmd 输入net stop mysql; 停止mysql  然后在开启 net start mysql;  这步是修改完文件后重启一下 然后在 输入 mysq

解决mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES)

1 现象 mysql -u root -p 错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES)2 linux系统: 在配置文件my-default.cnf或my.cnf下 [mysqld]下添加skip-grant-tables:因为此方法无效,所以找到了以下方法 为了加强安全性,MySQL5.7为root用户随机生成了一个密码,在error log中,关于error

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

最近操作mysql 5.6, 出现了以下问题. 分享,感谢原著: 案例环境: 操作系统 :Red Hat Enterprise Linux Server release 5.7 (Tikanga) 64 bit 数据库版本 : Mysql 5.6.19 64 bit 案例介绍: 今 天开始学习mysql,遂先安装了Mysql 5.6.19 64bit 版本的数据库,结果安装成功了,但是使用root登录时遇到了ERROR 1045 (28000): Access denied for user '

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

环境:mac10.12 来源:http://www.cnblogs.com/kerrycode/p/3861719.html 使用root登录时遇到了ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)错误. 如下所示 [[email protected] tmp]# rpm -ivh MySQL-server-5.6.19-1.rhel5.x86_64.rpm Preparing..

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

安装mysql后,使用命令登录mysql居然报错了,Mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost'(using password: YSE),这个错误搞得很郁闷,仔细分析之后,知道这个报错和密码有关,可能是密码在配置mysql的时候异常,所以导致我们没有正确的密码,知道问题后,立即想到解决办法了,那就是重新设置一个密码,方法如下 1.先关闭mysql并设置密码 #sudo /etc/init.d/mysql

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

MySQL安装完server端和客户端后,登录Mysql时报错:[[email protected] MySQL 5.6.23-RMP]# mysqlERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)[[email protected] MySQL 5.6.23-RMP]# service mysql startStarting MySQL.[