In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How to view the database in mysql? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!
You can use the "SHOW DATABASES" statement in mysql to view or display databases within the scope of the current user's permissions; the syntax format is "SHOW DATABASES [LIKE 'database name'];".
The database can be regarded as a container for storing data objects, each database has a unique name, and the name of the database is meaningful, so that you can clearly see what data each database uses to store. There are system database and custom database in the MySQL database. The system database is the database that comes with the system after installing MySQL, and the custom database is the database created by the user definition.
In MySQL, you can use SHOW DATABASES statements to view or display databases that are within the scope of the current user's permissions. The syntax format for viewing the database is:
SHOW DATABASES [LIKE 'database name']
The syntax is as follows:
The LIKE clause is optional and matches the specified database name. LIKE clauses can be partially matched or completely matched.
The database name is surrounded by single quotation marks''.
Example 1: view all databases
List all databases that can be viewed by the current user:
Mysql > SHOW DATABASES;+-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sakila | | sys | | world | +-+ 6 row in set (0.22 sec)
You can find that there are 6 databases in the above list, all of which are automatically created by the system when MySQL is installed, and their respective functions are as follows:
Information_schema: mainly stores some database object information in the system, such as user table information, column information, permission information, character set information and partition information.
The core database of mysql:MySQL, similar to the master table in SQL Server, is mainly responsible for storing the control and management information that MySQL needs to use, such as database users, user access rights and so on. Commonly used, such as changing the root user password in the user table of the mysql database.
Performance_schema: mainly used to collect database server performance parameters.
Sakila:MySQL provides a sample database, the database has a total of 16 tables, these data tables are relatively common, when designing the database, you can refer to these sample data tables to quickly complete the required data tables.
The installation of sys:MySQL 5.7 will result in an additional sys database. The sys database mainly provides some views, and the data comes from performation_schema, mainly to make it easier for developers and users to view performance issues.
World:world database is a database created automatically by MySQL, which contains only three data tables, which store the language used by city, country and country, etc.
Example 2: create and view a database
First create a database called test_db:
Mysql > CREATE DATABASE test_db;Query OK, 1 row affected (0.12 sec)
Then use the SHOW DATABASES statement to display all database names within the scope of permissions, as follows:
Mysql > SHOW DATABASES +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sakila | | sys | | test_db | | world | +-+ 7 row in set (0.22 sec)
You see, the database just created has been displayed.
Example 3: using LIKE clauses
First create three databases, named test_db, db_test, and db_test_db.
1) use the LIKE clause to view the database that exactly matches the test_db:
Mysql > SHOW DATABASES LIKE 'test_db';+-+ | Database (test_db) | +-+ | test_db | +-+ 1 row in set (0.03 sec)
2) use the LIKE clause to view the database whose name contains test:
Mysql > SHOW DATABASES LIKE'% test%' +-+ | Database (% test%) | +-+ | db_test | +-+ | db_test_db | +-+ | test_db | | +-+ 3 row in set (0.03 sec) |
3) use the LIKE clause to view the database whose name begins with db:
Mysql > SHOW DATABASES LIKE 'db%';+-+ | Database (db%) | +-+ | db_test | +-+ | db_test_db | +-+ 2 row in set (0.03 sec)
4) use the LIKE clause to view the database whose name ends in db:
Mysql > SHOW DATABASES LIKE'% db';+-+ | Database (% db) | +-+ | db_test_db | +-+ | test_db | +-+ 2 row in set (0.03 sec) Thank you for reading! After reading the above, do you have a general idea of how to view the database in mysql? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.