mysql重置密码
Linux环境下,忘记mysql密码怎么办?这里提供两种解决方案。
第一种方案:
在my.cnf配置文件中添加“跳过登陆密码验证”配置项
sed -i "/[mysqld]/ askip-grant-tables" /etc/my.cnf
重启mysqld守护进程,重新加载配置
service mysqld restart
直接无账户无密码登陆mysql
[root@pingkou-developer2 etc]# mysql Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 3 Server version: 5.5.51-log MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type "help;" or "h" for help. Type "c" to clear the current input statement.
重新设置root账户密码后,退出登录
mysql> update `mysql`.`user` set `password`=password("admin") where `user`="root"; Query OK, 0 rows affected (0.00 sec) Rows matched: 3 Changed: 0 Warnings: 0 mysql> exit; Bye
在my.cnf配置文件中,将skip-grant-tables配置项注释掉,加#注释
sed -i "s/skip-grant-tables/#&/" /etc/my.cnf
重启mysqld守护进程,重新加载配置
[root@pingkou-developer2 pingkou]# service mysqld restart Stopping mysqld: [ OK ] Starting mysqld: [ OK ]
使用新密码重新登陆mysql,结束
[root@pingkou-developer2 pingkou]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 4 Server version: 5.5.51-log MySQL Community Server (GPL) by Remi Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type "help;" or "h" for help. Type "c" to clear the current input statement. mysql>
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/23286.html
摘要:一安装看库中都有哪些版本选择版本进行安装设置环境变量并在里面加上如下内容按并保存退出使配置生效验证安装成功二安装下载的源安装包安装,根据提示安装就可以了不过安装完成后没有密码需要重置密码重置密码此时 一 安装jdk 1.8 1.看yum库中都有哪些jdk版本 [root@localhost ~]# yum search java|grep jdk 2.选择1.8版本进行安装 [root...
摘要:一安装看库中都有哪些版本选择版本进行安装设置环境变量并在里面加上如下内容按并保存退出使配置生效验证安装成功二安装下载的源安装包安装,根据提示安装就可以了不过安装完成后没有密码需要重置密码重置密码此时 一 安装jdk 1.8 1.看yum库中都有哪些jdk版本 [root@localhost ~]# yum search java|grep jdk 2.选择1.8版本进行安装 [root...
摘要:此时应先输入命令之后再输入命令即可执行成功最后输入以下命令来查看用户权限是否变更查看用户权限是否变更 运行环境 操作系统:Centos7 mariadb 版本:mysql Ver 15.1 Distrib 5.5.41-MariaDB, for Linux (x86_64) using readline 5.1 参考文献:参考博客 操作步骤 0.停止mariadb system...
摘要:受困于和版本问题,很多人经常会搭建失败,今天松哥就给大伙举一个成功的例子,后面有时间再和大家分享下使用搭建环境,那样就成功了。 这是松哥之前一个零散的笔记,整理出来分享给大伙! MySQL 读写分离在互联网项目中应该算是一个非常常见的需求了。受困于 Linux 和 MySQL 版本问题,很多人经常会搭建失败,今天松哥就给大伙举一个成功的例子,后面有时间再和大家分享下使用 Docker ...
摘要:受困于和版本问题,很多人经常会搭建失败,今天松哥就给大伙举一个成功的例子,后面有时间再和大家分享下使用搭建环境,那样就成功了。 这是松哥之前一个零散的笔记,整理出来分享给大伙! MySQL 读写分离在互联网项目中应该算是一个非常常见的需求了。受困于 Linux 和 MySQL 版本问题,很多人经常会搭建失败,今天松哥就给大伙举一个成功的例子,后面有时间再和大家分享下使用 Docker ...
阅读 2723·2023-04-26 02:25
阅读 1983·2023-04-25 18:05
阅读 434·2021-09-30 09:57
阅读 1987·2021-09-29 09:32
阅读 2684·2021-09-27 14:10
阅读 1464·2019-08-30 15:44
阅读 837·2019-08-29 15:28
阅读 2335·2019-08-29 14:10