MySQL is a widely used relational database management system. Most people who recognize this concept also clearly know that MySQL is a database. However, did you know that MySQL itself also has its own database? This database is named mysql.
In MySQL, the mysql database is used to store configuration information about users, permissions, and other system levels. Only users with specific permissions can view or change data in the mysql database.
So, how to view the mysql database?
1. Log in to MySQL
First, you need to log in to MySQL using an administrator account. You can access MySQL through the command line or using the MySQL graphical interface tool.
If you use the command line, the method is as follows:
mysql -u root -p
-u means specifying the user name, root is the default administrator account, you can also use other accounts with specific permissions;
-p means prompting for a password, just enter the correct password according to the system prompts .
2. View the mysql database
Once you successfully log in to MySQL, you can view the mysql database. In MySQL, the mysql database exists by default, and you can view all its tables and the data in them. The method is as follows:
show databases;
This command will list all databases you can access, including mysql , information_schema and other customized databases;
use mysql;
The function of this command is Switch to the mysql database, and then you can view all the data in the mysql database.
3. View the tables and data in the mysql database
If you have successfully loaded the mysql database, you can execute the following command to view all tables:
show tables;
This command will list all tables in the mysql database, such as user, db, tables_priv, etc. You can also view the structure and data of a specific table, for example:
select User, Host, Password from user;
select Db from db;
Summary
As you understand in this article As mentioned, MySQL itself also has its own database, named mysql, which is used to store system-level configuration information. Only users with specific permissions can view or change data in the mysql database. In MySQL, you can use command line or graphical interface tools to view the mysql database, and you can also use query statements to view the tables and data in the mysql database.
The above is the detailed content of How to view tables and data in mysql database. For more information, please follow other related articles on the PHP Chinese website!