
显示列出MySQL上的所有数据库步骤1.首先,通过apt在终端中运行以下以下命令,确保所有系统软件包都是最新的。
sudo apt update sudo apt upgrade
第2步。显示列出MySQL上的所有数据库
要在MySQL中显示数据库,您将需要以root用户登录MySQL / MariaDB shell,如下所示:
$ mysql –u username –p Enter password: Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 3 Server version: 5.8.64-MySQL-ubuntu0.20.04 (Ubuntu) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type \'help;\' or \'\\h\' for help. Type \'\\c\' to clear the current input statement. MariaDB [(none)]>
在MySQL Shell中执行以下命令:
MySQL [(none)]> show databases;
输出:
+--------------------+ | Database | +--------------------+ | information_schema | | drupal | | magento | | mysql | | owncloud | | performance_schema | | wordpressdatabase | +--------------------+ 7 rows in set (0.01 sec)
接下来,如果要使用特定的数据库并列出其中的所有表,则可以使用以下命令:
MySQL [(none)]> use mysql;
接下来,使用以下命令列出可用的表:
MySQL [mysql]> show tables;
输出:
+---------------------------+ | Tables_in_mysql | +---------------------------+ | columns_priv | | db | | event | | func | | general_log | | help_category | | help_keyword | | help_relation | | help_topic | | host | | ndb_binlog_index | | plugin | | proc | | procs_priv | | proxies_priv | | servers | | slow_log | | tables_priv | | time_zone | | time_zone_leap_second | | time_zone_name | | time_zone_transition | | time_zone_transition_type | | user | +---------------------------+
如果要查找特定表的结构,可以使用DESCRIBEMySQL中的语句:
MySQL [(none)]> DESCRIBE user;
恭喜你!您已成功显示所有数据库MySQL。感谢您使用本教程在Ubuntu 20.04 Focal Fossa系统中安装MySQL服务器。有关其他帮助或有用信息,我们建议您检查MySQL官方网站。