linux mysql提示1045_linux mysql ERROR 1045

介绍了一下安装MySQL后登陆MySQL时会遇到ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 这个错误,当时不知道真正的原因,搜索了一些网上的资料,测试验证了如何解决这个问题,但是一直不知道具体的原因。今天终于把这个问题给彻底搞清楚了。

下面我以MySQL 5.6.20为例子,刨析一下这个错误的真正原因,如下所示

[root@DB-Server tmp]# rpm -ivh MySQL-server-advanced-5.6.20-1.rhel5.x86_64.rpm

Preparing... ########################################### [100%]

1:MySQL-server-advanced ########################################### [100%]

warning: user mysql does not exist - using root

warning: group mysql does not exist - using root

2015-03-26 10:49:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2015-03-26 10:49:07 5082 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-03-26 10:49:07 5082 [Note] InnoDB: The InnoDB memory heap is disabled

2015-03-26 10:49:07 5082 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-03-26 10:49:07 5082 [Note] InnoDB: Memory barrier is not used

2015-03-26 10:49:07 5082 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-03-26 10:49:07 5082 [Note] InnoDB: Using Linux native AIO

2015-03-26 10:49:07 5082 [Note] InnoDB: Using CPU crc32 instructions

2015-03-26 10:49:07 5082 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-03-26 10:49:07 5082 [Note] InnoDB: Completed initialization of buffer pool

2015-03-26 10:49:07 5082 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!

2015-03-26 10:49:07 5082 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB

2015-03-26 10:49:07 5082 [Note] InnoDB: Database physically writes the file full: wait...

2015-03-26 10:49:07 5082 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB

2015-03-26 10:49:07 5082 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB

2015-03-26 10:49:08 5082 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0

2015-03-26 10:49:08 5082 [Warning] InnoDB: New log files created, LSN=45781

2015-03-26 10:49:08 5082 [Note] InnoDB: Doublewrite buffer not found: creating new

2015-03-26 10:49:08 5082 [Note] InnoDB: Doublewrite buffer created

2015-03-26 10:49:08 5082 [Note] InnoDB: 128 rollback segment(s) are active.

2015-03-26 10:49:08 5082 [Warning] InnoDB: Creating foreign key constraint system tables.

2015-03-26 10:49:08 5082 [Note] InnoDB: Foreign key constraint system tables created

2015-03-26 10:49:08 5082 [Note] InnoDB: Creating tablespace and datafile system tables.

2015-03-26 10:49:08 5082 [Note] InnoDB: Tablespace and datafile system tables created.

2015-03-26 10:49:08 5082 [Note] InnoDB: Waiting for purge to start

2015-03-26 10:49:08 5082 [Note] InnoDB: 5.6.20 started; log sequence number 0

2015-03-26 10:49:08 5082 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.

2015-03-26 10:49:08 5082 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.

A random root password has been set. You will find it in '/root/.mysql_secret'.

2015-03-26 10:49:09 5082 [Note] Binlog end

2015-03-26 10:49:09 5082 [Note] InnoDB: FTS optimize thread exiting.

2015-03-26 10:49:09 5082 [Note] InnoDB: Starting shutdown...

2015-03-26 10:49:10 5082 [Note] InnoDB: Shutdown completed; log sequence number 1625977

2015-03-26 10:49:10 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2015-03-26 10:49:10 5104 [Note] InnoDB: Using atomics to ref count buffer pool pages

2015-03-26 10:49:10 5104 [Note] InnoDB: The InnoDB memory heap is disabled

2015-03-26 10:49:10 5104 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2015-03-26 10:49:10 5104 [Note] InnoDB: Memory barrier is not used

2015-03-26 10:49:10 5104 [Note] InnoDB: Compressed tables use zlib 1.2.3

2015-03-26 10:49:10 5104 [Note] InnoDB: Using Linux native AIO

2015-03-26 10:49:10 5104 [Note] InnoDB: Using CPU crc32 instructions

2015-03-26 10:49:10 5104 [Note] InnoDB: Initializing buffer pool, size = 128.0M

2015-03-26 10:49:10 5104 [Note] InnoDB: Completed initialization of buffer pool

2015-03-26 10:49:10 5104 [Note] InnoDB: Highest supported file format is Barracuda.

2015-03-26 10:49:10 5104 [Note] InnoDB: 128 rollback segment(s) are active.

2015-03-26 10:49:10 5104 [Note] InnoDB: Waiting for purge to start

2015-03-26 10:49:10 5104 [Note] InnoDB: 5.6.20 started; log sequence number 1625977

2015-03-26 10:49:10 5104 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.

2015-03-26 10:49:10 5104 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.

2015-03-26 10:49:10 5104 [Note] Binlog end

2015-03-26 10:49:10 5104 [Note] InnoDB: FTS optimize thread exiting.

2015-03-26 10:49:10 5104 [Note] InnoDB: Starting shutdown...

2015-03-26 10:49:12 5104 [Note] InnoDB: Shutdown completed; log sequence number 1625987

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,

no other statement but 'SET PASSWORD' will be accepted.

See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

/usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.

This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

WARNING: Found existing config file /usr/my.cnf on the system.

Because this file might be in use, it was not replaced,

but was used in bootstrap (unless you used --defaults-file)

and when you later start the server.

The new default config file was created as /usr/my-new.cnf,

please compare it with your file and take the changes you need.

MySQL的安装日志信息中,你会看到MySQL生成了root用户的随机密码(如下截图所示),并将这个随机密码放置在/root/.mysql_secret中。并且强制在第一次登陆时修改root用户的密码。Mysql 5.6及以后版本出处于安全考虑,root密码不为空。所以在MySQL的安装过程中,会生成一个随机密码,但是对于我们这样的初学者,不了解情况,于是便从网上搜索如何解决问题的资料,而问题关键在此,很多做技术的人,了解不够深入,又喜欢随波逐流,停留在问题的表层,并未深入研究。而高手又不屑于这类简单的问题。

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !

You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,

no other statement but 'SET PASSWORD' will be accepted.

See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

知道了错误的前因后果,那么很容易就搞定这个问题了。找到随机密码,登录数据库后修改密码。问题解决

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/500953.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql原生库_Mysql数据库的一些简单原生sql语句

原生sql语句查询:select * from 表名 :查找表内所有数据, * 代表所有where 具体条件 :where作位查询sql语句条件,例 select * from 表名 where 字段名指定值order by 升降序:与desc和asc使用,通常以int类型字段进行升…

有向图生成树是如何画的_漫画:什么是最小生成树?

作者 | 小灰来源 | 程序员小灰————— 第二天 —————————————————首先看看第一个例子,有下面这样一个带权图:它的最小生成树是什么样子呢?下图绿色加粗的边可以把所有顶点连接起来,又保证了边的权值之和最小&a…

python经济_python生成器——懒到欠揍,但很经济

生成器的特点是工作到一半,就会停下来看别人干活直至有人踢它屁股,这时它才继续往下干活。实现这一功能的精髓要用到yield。生成器是一种特殊的迭代器,因此我们先来了解一下什么是迭代器。我们都知道著名的斐波那契数列:1、1、2、…

ue默认高亮mysql_UE设置打开文件的默认高亮语言

最近使用UE时,需要频繁地打开.ec文件,.ec文件参照的是C/C的语法,每次打开时,都需要在工具栏上点击“查看方式->C/C”。觉得很繁琐,于是想查找一下设置,让UE打开.ec文件时,默认使用的C/C语法高…

printf 指针地址_c语言对指针的理解

先来讲一下本人学指针的经历:大一的时候刚接触c语言对指针这东西真的是太迷了,感觉麻烦难懂不想其他语言一样。但是搞懂以后就被指针的魅力吸引甚至喜欢上c语言。不多讲,开始!(文章可能有些长,但放心全是基础的东西&am…

mysql 命令 _Mysql常用命令行大全

7.1 一个建库和建表的实例1drop database if exists school; //如果存在SCHOOL则删除create database school; //建立库SCHOOLuse school; //打开库SCHOOLcreate table teacher //建立表TEACHER(id int(3) auto_increment not null primary key,name char(10) not null,address…

python进程监控 supervisor_使用Python的Supervisor进行进程监控以及自动启动

做服务器端开发的同学应该都对进程监控不会陌生,最近恰好要更换 uwsgi 为 gunicorn,而gunicorn又恰好有这么一章讲进程监控,所以多研究了下。结合之前在腾讯工作的经验,也会讲讲腾讯的服务器监控是怎么做的。同时也会讲下小团队又…

python 时分秒毫秒_python将时分秒转换成秒的实例

处理数据的时候遇到一个问题,从数据库里导出的数据是时分秒的格式:hh:mm:ss ,现在我需要把它转换成秒,方便计算。原数据可能分两种情况,字段有可能是文本字符串类型的,也有可能是时间类型,他们的…

信息系统项目管理师论文优秀范文_软考 信息系统项目管理师备考指南

1.考试简介信息系统项目管理师考试作为全国计算机技术与软件专业技术资格(水平)考试(一般简称为“软考”)的一个高级级别,是从2005年开始的,一共考了2次,即2005年5月,200…

单片机led闪烁代码_单片机驱动LED发光二极管的电路以及编程

一、单片机驱动单个发光二极管1.电路代码:1.点亮单个LED二极管#include《reg51.h> sbit LED1P1^0&#xff1b;void main(void){LED11&#xff1b;while(1)&#xff1b;{LED10} }2.单个LED数码管以固定频率闪烁#include<reg51.h> sbit LED1P1^0;void Delay(unsigned in…

mysql人事管理系统源代码_人事管理系统(源代码.doc

人事管理系统(源代码附录&#xff1a;毕业设计程序清单设计题目 人事管理系统教 学 班&#xff1a;学生姓名&#xff1a;学 号&#xff1a;指导教师&#xff1a;完成日期&#xff1a;Option ExplicitDim Bupdata As BooleanDim i As IntegerPrivate Sub Cmbdegree_Click()If Cm…

python实时数据流_python – 使用烧瓶web-app监控实时数据流

这是基于https://stackoverflow.com/a/13388915/819544发布的答案我想监视一个数据流并将其推送到类似于上面答案的前端,但是一旦应用程序启动,流就开始生成/监视数据,并且客户端总是看到当前的状态数据流(无论是否从服务器请求数据,它都会继续运行).我很确定我需要通过线程将数…

macos系统自动安装mysql_macos系统安装mysql

MacOS系统安装mysql一、下载官网下载链接地址&#xff1a;https://dev.mysql.com/downloads/mysql/二、安装打开文件是pkg包&#xff0c;双击进行安装&#xff1a;按照提示&#xff1a;点击最下面的MySQL控制按钮&#xff0c;启动数据库运行&#xff1a;在此可以启动和停止MySQ…

水晶报表中对某一栏位值进行处理_合并报表——非同一控制下的企业合并amp;同一控制下的企业合并...

【写在前面】长期股权投资企业的一种投资行为&#xff0c;投资方通过该行为享有被投资单位的股利分配、净利润等投资收益&#xff0c;处理的是母公司&#xff08;投资方&#xff09;的个别财务报表。只有控股合并才需要编制合并报表&#xff0c;意味着后续计量采用的是成本法。…

mysql和springboot对照_SpringBoot(六) SpirngBoot与Mysql关系型数据库

pom.xml文件的配置org.springframework.bootspring-boot-starter-jdbcmysqlmysql-connector-javaruntime写配置文件spring.datasource.url jdbc:mysql://localhost:3306/spring?useUnicodetrue&characterEncodingutf-8spring.datasource.username rootspring.datasource…

python创建数据库计算机积极拒绝、无法连接_Python3 请求网页源码 目标计算机积极拒绝,无法连接...

代码&#xff1a;import urllibfrom urllib.request import urlopenfrom urllib.parse import urlencodeurlhttp://xxx.xxxx.com/ //测试链接resurlopen(url)#通过urlopen方法访问拼接好的urlresres.read().decode()#read()方法是读取返回数据内容&#xff0c;decode是转换返回…

python测试框架untest怎么循环执行_unittest如何在循环遍历一条用例时生成多个测试结果...

引用自:http://blog.csdn.net/kaku21/article/details/42124593参考网址&#xff1a;http://programmaticallyspeaking.com/test-data-provider-using-python-metaclass.html使用TestNG进行测试的时候&#xff0c;允许使用外部数据源来驱动测试方法的执行&#xff0c;举个例子&…

python杨辉三角_yiduobo的每日leetcode 118.杨辉三角 amp;amp; 119.杨辉三角II

祖传的手艺不想丢了&#xff0c;所以按顺序写一个leetcode的题解。计划每日两题&#xff0c;争取不卡题吧。118.杨辉三角https://leetcode-cn.com/problems/pascals-triangle/119.杨辉三角IIhttps://leetcode-cn.com/problems/pascals-triangle-ii/经典的数学题。118题需要求出…

mysql 字段a减字段b_SQL 数据库 如何实现第一行字段A减字段B得到值C,然后再用C减去第二行字段B,以此类推,求高手解答...

select * ,0 as 缺货 into tmp_r from table_1 --创建结果表declare i intdeclare j intdeclare q intselect row_number() over(order by 子件S) as id,子件S,现存量 into #tmp_s from table_1 group by 子件S,现存量 --第一个临时表将子件S列出来set i 1while (i<(select …

python历史背景_python学习之旅1-1(python背景、安装介绍)

一、python介绍1.python历史背景python的创始人为吉多范罗苏姆(Guido van Rossum)。1989年的圣诞节期间&#xff0c;吉多范罗苏姆(中文名字&#xff1a;龟叔)为了在阿姆斯特丹打发时间&#xff0c;决心开发一个新的脚本解释程序&#xff0c;作为ABC语言的一种继承。1989年&…