如何查看MySQL连接的root密码
作者:宫城 时间:2024-01-25 08:47:43
本文给大家分享的是查看MySQL连接的root密码的方法,下面话不多说来来看正文:
1.首先我们进到MySQL的bin目录下
➜ cd /usr/local/mysql/bin
2.切换成root身份
➜ bin sudo su
3.跨过权限的验证
sh-3.2# ./mysqld_safe --skip-grant-tables &
[1] 9451
sh-3.2# 2017-01-03T15:40:10.6NZ mysqld_safe Logging to '/usr/local/mysql/data/yzydeMacBook-Pro.local.err'.
2017-01-03T15:40:10.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
4.以root身份登录MySQL
./mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.12 MySQL Community Server (GPL)
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.
5.选择mysql数据库
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
6.显示mysql数据库下的表
mysql> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| engine_cost |
| event |
| func |
| general_log |
| gtid_executed |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| server_cost |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
31 rows in set (0.00 sec)
7.很明显我们需要的密码是存在user这个表下的,所以我们直接看user的表结构是怎么样的
mysql> show columns from user;
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(32) | NO | PRI | | |
| Select_priv | enum('N','Y') | NO | | N | |
| Insert_priv | enum('N','Y') | NO | | N | |
| Update_priv | enum('N','Y') | NO | | N | |
| Delete_priv | enum('N','Y') | NO | | N | |
| Create_priv | enum('N','Y') | NO | | N | |
| Drop_priv | enum('N','Y') | NO | | N | |
| Reload_priv | enum('N','Y') | NO | | N | |
| Shutdown_priv | enum('N','Y') | NO | | N | |
| Process_priv | enum('N','Y') | NO | | N | |
| File_priv | enum('N','Y') | NO | | N | |
| Grant_priv | enum('N','Y') | NO | | N | |
| References_priv | enum('N','Y') | NO | | N | |
| Index_priv | enum('N','Y') | NO | | N | |
| Alter_priv | enum('N','Y') | NO | | N | |
| Show_db_priv | enum('N','Y') | NO | | N | |
| Super_priv | enum('N','Y') | NO | | N | |
| Create_tmp_table_priv | enum('N','Y') | NO | | N | |
| Lock_tables_priv | enum('N','Y') | NO | | N | |
| Execute_priv | enum('N','Y') | NO | | N | |
| Repl_slave_priv | enum('N','Y') | NO | | N | |
| Repl_client_priv | enum('N','Y') | NO | | N | |
| Create_view_priv | enum('N','Y') | NO | | N | |
| Show_view_priv | enum('N','Y') | NO | | N | |
| Create_routine_priv | enum('N','Y') | NO | | N | |
| Alter_routine_priv | enum('N','Y') | NO | | N | |
| Create_user_priv | enum('N','Y') | NO | | N | |
| Event_priv | enum('N','Y') | NO | | N | |
| Trigger_priv | enum('N','Y') | NO | | N | |
| Create_tablespace_priv | enum('N','Y') | NO | | N | |
| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | | | |
| ssl_cipher | blob | NO | | NULL | |
| x509_issuer | blob | NO | | NULL | |
| x509_subject | blob | NO | | NULL | |
| max_questions | int(11) unsigned | NO | | 0 | |
| max_updates | int(11) unsigned | NO | | 0 | |
| max_connections | int(11) unsigned | NO | | 0 | |
| max_user_connections | int(11) unsigned | NO | | 0 | |
| plugin | char(64) | NO | | mysql_native_password | |
| authentication_string | text | YES | | NULL | |
| password_expired | enum('N','Y') | NO | | N | |
| password_last_changed | timestamp | YES | | NULL | |
| password_lifetime | smallint(5) unsigned | YES | | NULL | |
| account_locked | enum('N','Y') | NO | | N | |
+------------------------+-----------------------------------+------+-----+-----------------------+-------+
45 rows in set (0.02 sec)
8.表的内容比较多,但是我们很容易就发现,密码其实是存在authentication_string字段下的,那我们就可以直接读User内容为root的密码了
mysql> select authentication_string from user where User='root';
+-------------------------------------------+
| authentication_string |
+-------------------------------------------+
| *781D25322166DB7FF99BA4A1FA5ED30439A60DDE |
+-------------------------------------------+
1 row in set (0.01 sec)
OK,那我们拿着这个密码到Navicat试试看
总结
好了,以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。
来源:http://zeeyang.com/2017/01/04/Check-MySQL-Password/
标签:mysql,root,密码
0
投稿
猜你喜欢
Golang最大递减数算法问题分析
2023-07-16 13:49:21
centos下安装配置phpMyAdmin的方法步骤
2023-11-09 01:27:11
opencv python 图片读取与显示图片窗口未响应问题的解决
2021-05-15 22:08:53
javascript自定义加载loading效果
2024-04-27 15:23:14
python实现csv格式文件转为asc格式文件的方法
2021-10-12 19:10:37
Pandas数据处理加速技巧汇总
2023-08-12 19:02:36
python3实现TCP协议的简单服务器和客户端案例(分享)
2023-01-11 13:11:21
asp网上考试设计思路是怎样的?
2010-07-14 21:09:00
MySQL全局共享内存介绍
2024-01-14 09:40:14
浅析Flask如何使用日志功能
2023-06-17 17:18:21
python判断变量是否为列表的方法
2023-05-06 16:22:22
Pytorch可视化之Visdom使用实例
2021-01-05 12:16:13
python使用win32com在百度空间插入html元素示例
2021-09-13 17:00:13
python实现用户登录系统
2023-10-13 13:17:22
Python中str is not callable问题详解及解决办法
2023-10-30 05:34:42
python使用tkinter模块实现文件选择功能
2022-06-18 18:35:56
详解Python操作Excel之openpyxl
2021-10-13 05:13:21
Python中shutil模块的学习笔记教程
2022-12-22 20:42:05
python实时检测键盘输入函数的示例
2023-01-27 19:19:28
vue 全局引用公共的组件以及公共的JS文件问题
2024-05-29 22:44:46