How to view the MySQL root Password and mysqlroot Password

Source: Internet
Author: User

How to view the MySQL root Password and mysqlroot Password

This article will share with you how to view the root password of a MySQL connection. Let's talk about the text below:

1. First, go to the MySQL bin directory.

➜ cd /usr/local/mysql/bin

2. Switch to the root identity

➜ bin sudo su

3. Cross-Permission Verification

sh-3.2# ./mysqld_safe --skip-grant-tables &[1] 9451sh-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. log on to MySQL as root

./mysql -urootWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

5. Select mysql database

mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changed

6. display tables in the mysql database

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. Obviously, the password we need exists in the user table, so let's look at the structure of the user table.

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. There are many table contents, but we can easily find that the password actually exists in the authentication_string field, so we can directly read the password whose User content is root.

mysql> select authentication_string from user where User='root';+-------------------------------------------+| authentication_string      |+-------------------------------------------+| *781D25322166DB7FF99BA4A1FA5ED30439A60DDE |+-------------------------------------------+1 row in set (0.01 sec)

Okay, let's try Navicat with this password.

 

Summary

Well, the above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.