mysql查看root密码是什么的方法
小编给大家分享一下mysql查看root密码是什么的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!
查看mysqlroot密码的方法:
1、首先我们进到MySQL的bin目录下
cd/usr/local/mysql/bin
2、切换成root身份
binsudosu
3、跨过权限的验证
sh-3.2#./mysqld_safe--skip-grant-tables&[1]9451sh-3.2#2017-01-03T15:40:10.6NZmysqld_safeLoggingto'/usr/local/mysql/data/yzydeMacBook-Pro.local.err'.2017-01-03T15:40:10.6NZmysqld_safeStartingmysqlddaemonwithdatabasesfrom/usr/local/mysql/data
4、以root身份登录MySQL
./mysql-urootWelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis2Serverversion:5.7.12MySQLCommunityServer(GPL)Copyright(c)2000,2016,Oracleand/oritsaffiliates.Allrightsreserved.OracleisaregisteredtrademarkofOracleCorporationand/oritsaffiliates.Othernamesmaybetrademarksoftheirrespectiveowners.Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
5、选择mysql数据库
mysql>usemysqlReadingtableinformationforcompletionoftableandcolumnnamesYoucanturnoffthisfeaturetogetaquickerstartupwith-ADatabasechanged
6、显示mysql数据库下的表
mysql>showtables;+---------------------------+|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|+---------------------------+31rowsinset(0.00sec)
7、很明显我们需要的密码是存在user这个表下的,所以我们直接看user的表结构是怎么样的
mysql>showcolumnsfromuser;+------------------+-----------------------+------+-----+------------+-------+|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||+--------------------+---------------------+------+-----+------------+-------+45rowsinset(0.02sec)
8、表的内容比较多,但是我们很容易就发现,密码其实是存在authentication_string字段下的,那我们就可以直接读User内容为root的密码了
mysql>selectauthentication_stringfromuserwhereUser='root';+-------------------------------------------+|authentication_string|+-------------------------------------------+|*781D25322166DB7FF99BA4A1FA5ED30439A60DDE|+-------------------------------------------+1rowinset(0.01sec)
看完了这篇文章,相信你对mysql查看root密码是什么的方法有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。