尝试确认MariaDB的表定义
环境
-
CentOS Linux release 7.4.1708 (Core)
MariaDb 5.5.56
确认MariaDB的表定义
怎么办来着?我先记下来。
记录下在MariaDB上确认数据库、表和列的步骤。
通过本地连接进行确认。
显示的数据库和表是安装时的默认设置。
无需密码,通过根目录进入。
当设置了根路径的密码时会出现错误。
[root@localhost etc]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
以密码方式进入根目录。
输入密码:要求输入数据库的根密码。
[root@localhost etc]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 27
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
数据库列表
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
选择数据库
选择MySQL。
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MySQL 的表格清单
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
... 省略 ...
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
24 rows in set (0.00 sec)
用户表的列清单
我能通过以下命令确认到:
-
show columns from テーブル名
show fields from テーブル
describe テーブル名
explain テーブル名
MariaDB [mysql]> show columns from user;
+------------------------+-----------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+-----------------------------------+------+-----+---------+-------+
| Host | char(60) | NO | PRI | | |
| User | char(16) | NO | PRI | | |
... 省略 ...
| authentication_string | text | NO | | NULL | |
+------------------------+-----------------------------------+------+-----+---------+-------+
42 rows in set (0.00 sec)
用户列表
MariaDB [(none)]> select user,host from mysql.user;
+------+-----------------------+
| user | host |
+------+-----------------------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | localhost.localdomain |
| root | localhost.localdomain |
+------+-----------------------+
6 rows in set (0.00 sec)
执行SQL
MariaDB [mysql]> select * from user;
+-----------------------+------+-------
... 省略
重设密码
很久没有使用,重新登录时忘记了密码。
参考:MariaDB(MySQL)密码重置。