发布于 2016-03-30 10:45:25 | 212 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的Mysql教程,程序狗速度看过来!

Mysql关系型数据库管理系统

MySQL是一个开放源码的小型关联式数据库管理系统,开发者为瑞典MySQL AB公司。MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。


本文给大家记录的是个人在linux下使用root用户登录mysql的时候遇到的一个错误的解决方法,非常的简单实用,有需要的小伙伴可以参考下。

最近在centOS 7上,通过yum安装了mysql,安装成功后,使用root登录,出现了如下报错:


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

mysql版本为:Ver 14.14 Distrib 5.7.10, for Linux(X86_64) using EditLine wrapper

然而实际上并没有进行过root密码设置(不知道是不是安装过程有被忽略的地方?)。

对此就各种寻找答案,大致有下面一些情况:

有说root的随机密码位于/root/.mysql_secret中,但是我根本没有/root/.mysql_secret文件。有文章表示


> ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
> password: NO) :表示没有生成root的临时密码
> 
> ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
> password: YES) :表示生成了root的临时密码。

有些资料说root的默认密码为空,经过确认那是以前的老版本,Mysql 5.6及以后版本出处于安全考虑,root密码已经不为空了。
最终找到对我来说有用的解决方案。

产生原因:


Now that the password MySQL had generated is expired, the problem is reduced to getting this password to work again (1) or generate a new one (2). This can be accomplished by running MySQL with the skip-grant-tables option which would make it ignore the access rights:

解决方法:



Stop your MySQL server.

Add skip-grant-tables at the end of the [mysqld] section of my.cnf file and save it.

Start MySQL server.

In terminal, typemysql -u root -pto get into MySQL command prompt.

In the command prompt, typeUSE mysql;to get into the mysql database where it keeps database users.

Type

UPDATE user SET password_expired = 'N' WHERE User = 'root';

to let MySQL know the password is not expired (1) or

UPDATE user SET authentication_string = PASSWORD('YourNewPassword'), password_expired = 'N' WHERE User = 'root';

附上链接:Unable to access MySQL after it automatically generated a temporary password

发布出来,供大家参考。



最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务