前段时间不知道什么原因在Linux终端中出现无法启动Mysql的情况,在Linux终端中输入 mysql -uroot -p密码 的时候出现了下面这个错误:

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

在网上找了很多解决错误的方法,但跟我的解法方法有些差异,故记录下来以备他人鉴阅。
解决这个错误的关键在于重置Mysql的登录密码。

首先我们先进入到Linux计算机文档界面,如图:


etc目录下有一个mysql文件夹,网上很多教程的解决方法时候打开etc目录下的my.cnf文件,文件中有一个[mysqld]字段,在这个[mysqld]字段下添加一句skip-grant-tables但是我打开我的my.cnf文档后发现并没有这个字段,网上还有一种说法是打开my.ini文件,我试了下同样没找到,打开后如图所示:


那么这个[mysqld]字段到底在哪个文档里呢?
找了半天终于在我的/etc/mysql.conf.d/ 文件夹下有一个mysqld.cnf文档,在这个文档里可以找到【mysqld】字段,如图:
我们可以这样直接打开这个mysqld.cnf文档,但它是只读模式,是无法进行编辑保存的。(这里我已经在[mysqld]字段下添加过skip-grant-table了,在图中可以看到,作用是可以免密登录)

那么我们怎么编辑这个mysqld.cnf文档呢?
在终端中先cd到这个文档的上一级文件夹中
我的是:
在Linux终端输入:
cd /etc/mysqld.conf.d (进入到这个文件夹中)
然后需要用权限打开这个mysqld.cnf 文件

sudo  vi  mysqld.cnf
然后找到字段【mysqld】,进入编辑模式(按“i”键),在下面添加skip-grant-tables
当然如果你的[mysqld]字段在my.cnf或者my.ini文档中的话也是这样操作,进入到相应的文件夹中,
打开相应文件,在字段【mysqld】,进入编辑模式(按“i”键),在下面添加skip-grant-tables添加完成之后,按esc键退出编辑模式,然后:wq进行保存并退出。

接下里的就比较简单了
重启mysql
在终端中输入:

/etc/init.d/mysql restart
然后进入Mysql
mysql -uroot -p  (因为已经进行了免密登录操作,此处不用输入密码)
然后进行重置密码:
mysql> update mysql.user set authentication_string=password('你要重置的密码') where user='root' ;(最后不要忘记加";")如果此处报错,是因为你的mysql版本比较新,这种重置密码的语句已经过时了,你可以用以下语句重置密码:mysql> update mysql.user set password=password('你要重置的密码') where user='root' and host='localhost';
总有一个好用,信我哥们!(嘿嘿)
下一步:
mysql> flush privileges;
mysql> exit

至此,已完成重置密码的操作,可以重新打开一个终端,输入命令:mysql -uroot -p你的密码

此时应该可以正常登陆了。
嘿嘿

mysql: [Warning] Using a password on the command line interface can be insecure.(using password:YES)相关推荐

  1. mysql备份时过滤掉某些库 以及 去掉Warning: Using a password on the command line interface can be insecure.提示信息...

    在对mysql进行完整备份时使用--all-database参数 # mysqldump -u root -h localhost -p --all-database > /root/all.s ...

  2. 已解决:mysql: [Warning] Using a password on the command line interface can be insecure.

    在执行命令时候报错 mysql: [Warning] Using a password on the command line interface can be insecure. 解决 将密码改为后 ...

  3. 登录mysql时遇到了:mysql: [Warning] Using a password on the command line interface can be insecure.

    登录mysql时遇到了:mysql: [Warning] Using a password on the command line interface can be insecure. 问题: [ro ...

  4. mysql: “Warning: Using a password on the command line interface can be insecure.“ 解决方法

    mysql: "Warning: Using a password on the command line interface can be insecure." 解决方法 参考文 ...

  5. mysql: [Warning] Using a password on the command line interface can be insecure.解决方法

    1.在使用mysql命令的时候,出现问题: https://www.cndba.cn/hbhe0316/article/22635 https://www.cndba.cn/hbhe0316/arti ...

  6. [Warning] Using a password on the command line interface can be insecure.

    mysql: [Warning] Using a password on the command line interface can be insecure. 来自TMySQL用户,包括很多开发和G ...

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

    MySQL5.6之后的版本在通过客户端连接或者备份时时都会有出现如下的一个警告: Warning: Using a password on the command line interface can ...

  8. MySQL 基准测试(mysqlslap)出现 Using a password on the command line interface can be insecure 警告

    问题描述:在使用 mysqlslap 进行基准测试时,出现警告 mysqlslap: [Warning] Using a password on the command line interface ...

  9. Using a password on the command line interface can be insecure,mysql报错解决办法

    mysql数据库升级后原先的数据库取数脚本使用 mysql -uname -ppassword 的方式登录数据库,但是现在报错'Using a password on the command line ...

最新文章

  1. python 手动读取cifar10_Python读入CIFAR-10数据库
  2. musical.ly体验-这款国产外销的APP凭什么登上美国榜首?
  3. html日期写入数据库,javascript – 在HTML5 Web SQL数据库中对日期时间进行排序
  4. 如何在 C# 中使用 RabbitMQ
  5. 【渝粤题库】陕西师范大学700011 新课程改革与生物教材研究
  6. 修改 Mac 版 Safari、Chrome、FireFox、Opera 的 User-Agent
  7. dfs dtft dft fft
  8. 效果过度transition:all
  9. Java并发(三),孔浩java视频百度云盘
  10. 什么是CDN,网站被攻击时该怎么防
  11. Alink漫谈(二十二) :源码分析之聚类评估
  12. 【云原生】还不会使用linux?快看这里,在window快速安装centos系统
  13. 为什么那么都程序员不敢学Python?
  14. 水果销售系统功能设计
  15. ActiveMQ--概述
  16. ThreeJS后期处理
  17. WebView(一)
  18. 机器学习(七) 自编码器
  19. 50件事爸爸一定要与孩子做(转)
  20. 第三十七篇 场效应管模拟开关举例

热门文章

  1. 【转】学习如何学习的算法:简述元学习研究方向现状
  2. 聚通达科技java面试_面试官就这么欺负人:new Object()到底占用几个字节?
  3. 根据某天或某月是否是节假休息日
  4. python应用体系_python
  5. 在 Python 中构建一体化音频分析工具包,在一个地方分析您的音频文件
  6. 基于新闻数据的社交网络图数据分析实战
  7. 单缝衍射的相对光强分布matlab代码
  8. 当前微型计算机常用的外,当前微型计算机常用的外存储器中,大部分不包括_______。...
  9. 生活哲理故事系列之四(转贴)
  10. Linux内核源代码情景分析笔记