"""
centos:
mysql忘记root密码解决

1.修改MySQL的登录设置:
# vim /etc/my.cnf
在[mysqld]的段中加上一句:skip-grant-tables
例如:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-grant-tables

2.重启mysql
systemctl restart mysqld.service

3.登录mysql
mysql

4.修改root用户密码:
先将密码设置为空
update user set authentication_string='' where user='root'
再修改密码
ALTER user 'root'@'localhost' IDENTIFIED BY 'Cliu123#'
如果遇到The MySQL server is running with the --skip-grant-tables option
so it cannot execute this statement 则刷新权限即可(FLUSH PRIVILEGES)
注意: 一定不要采取如下形式该密码:
use mysql;
update user set authentication_string="newpassword" where user="root";
这样会给user表中root用户的authentication_string字段下设置了newpassword值;

当再使用ALTER USER 'root'@'localhost' IDENTIFITED BY 'newpassword'时会报错的;

因为authentication_string字段下只能是mysql加密后的41位字符串密码;其他的会报格式错误;
5.编辑my.cnf文件删掉skip-grant-tables 这一行

6.重启mysql

为用户授权并用于远程连接
GRANT ALL PRIVILEGES ON *.* TO 'tny'@'localhost' IDENTIFIED BY 'Test123456!' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'tny'@'10.18.192.52' IDENTIFIED BY 'Test123456!' WITH GRANT OPTION;
mysql8.0给用户授权时需要先创建用户:
create user 'zac'@'%' identified by 'Za888888!';
GRANT EXECUTE,INSERT,SELECT,UPDATE ON *.* TO 'tny'@'%';
grant on tpservice22.* to 'tny'@'%' ;
客户端使用密码验证,进行登录
ALTER USER 'tny'@'%' IDENTIFIED WITH mysql_native_password BY 'Za888888!';
FLUSH PRIVILEGES;
将用户加入组
usermod -a -G mysql root

grant all privileges on *.* to 'root'@'10.18.192.52' identified by "Test123456!" ;
"""

mysql root password的更多相关文章

  1. Linux - Reset a MySQL root password

    Use the following steps to reset a MySQL root password by using the command line interface. Stop the ...

  2. mysql forget root password

    http://www.rackspace.com/knowledge_center/article/mysql-resetting-a-lost-mysql-root-password MySQL - ...

  3. windows下新安装的mysql修改root password问题

    常用步骤: 1. 在my.ini中的mysqld下添加一行 skip-grant-tables 2.重启mysql后直接进入后,用SQL直接修改password列: C:\> net stop ...

  4. MYSQL更改root password时遇到Access Denied的解决办法

    今天在公司虚拟机上装MYSQL之后需要修改root password,然而遇到这样的错误: Access denied for user 'root'@'localhost' (using passw ...

  5. MYSQL安装时解决要输入current root password的解决方法

    在装MYSQL的时候发现要输入current root password不记得以前在电脑里装过(你的系统曾经装过MYSQL在重装就会要求输入原来设定的密码,如果是第一次安装就不会出现),在网上苦苦搜寻 ...

  6. Mysql安装配置以及解决重装Mysql时忘记root password问题

    目录 1.Mysql安装以及环境变量配置 重装Mysql时忘记root password问题 1.Mysql安装以及环境变量配置 官网安装:​​​​​​https://www.mysql.com/ 按 ...

  7. MySQL root密码找回

    以MySQL多实例为例,演示找回MySQL root的密码 1.关闭mysql服务 [root@mysql ~]# mysqladmin -uroot -poldboy123 -S /data/330 ...

  8. mysql root 维护

    修改root密码: mysql -uroot -paaamysql> use mysql;mysql> UPDATE user SET password=password("aa ...

  9. MySQL root密码重置 报错:mysqladmin: connect to server at 'localhost' failed的解决方案

    ===========================================================二,忘记本地root的登录密码解决过程:1.编辑/mysql/my.ini在[my ...

随机推荐

  1. Thread中yield方法

    先上一段代码 public class YieldExcemple { public static void main(String[] args) { Thread threada = new Th ...

  2. 多线程中的event,用于多线程的协调

    ''' 简单的需求:红绿灯,红灯停,绿灯行 一个线程扮演红绿灯,每过一段时间灯变化,3-5个线程扮演车,红灯停,绿灯行 红绿灯线程和车的线程会相互依赖 这种场景怎么实现?---事件 切换一次灯就是一次 ...

  3. 爬虫系列---scrapy全栈数据爬取框架(Crawlspider)

    一 简介 crawlspider 是Spider的一个子类,除了继承spider的功能特性外,还派生了自己更加强大的功能. LinkExtractors链接提取器,Rule规则解析器. 二 强大的链接 ...

  4. Ajax 与文件上传

    一 Ajax篇 1 ajax简介(Asynchronous Javascript And XML) 异步,Js,XML,即使用Javascript语言与服务器进行异步交互,传输的数据为xml(可扩展标 ...

  5. c++11の数据竞争和互斥对象

    一.数据竞争的产生 在下面例子中: void function_1() { ; i < ; i++) { std::cout << "from function 1:&qu ...

  6. mmap:速度快+整块操作

    mmap使得可以将设备内存映射到用户空间,从而使得用户程序获得访问硬件的能力,mmap的动作需要由内核中的驱动来实现.在使用mmap映射后,用户程序对给定范围的内存的读写就变成了对设备内存的读写,也就 ...

  7. 013_实践HTTP206状态:部分内容和范围请求

    HTTP 2xx范围内的状态码表明了:"客户端发送的请求已经被服务器接受并且被成功处理了".HTTP/1.1 200 OK是HTTP请求成功后的标准响应,当你在浏览器中打开www. ...

  8. exgcd

    int exgcd(int a,int b,int &x,int &y){ if (b==0){ x=1,y=0; return a; } int d=exgcd(b,a%b,y,x) ...

  9. UUID简记

    一.概述 wiki上的解释: A universally unique identifier (UUID) is a 128-bit number used to identify informati ...

  10. JS-数组操作3

    1. 找出数组 arr 中重复出现过的元素 function duplicates(arr) { var result = []; var count = []; for (var i=0;i< ...