日常操作管理
-
创建用户
MariaDB [(none)]> create user WTF@'%' identified by 'WTF';
Query OK, 0 rows affected (0.03 sec) -
授权
MariaDB [(none)]> grant all privileges on WTF.* to WTF;
Query OK, 0 rows affected (0.00 sec) -
修改密码
MariaDB [(none)]> set password root@'localhost'=password('leo'); -
创建索引
- CREATE INDEX可对表增加普通索引或UNIQUE索引。
CREATE INDEX index_name ON table_name (column_list)
CREATE UNIQUE INDEX index_name ON table_name (column_list)
- ALTER TABLE用来创建普通索引、UNIQUE索引或PRIMARY KEY索引。
ALTER TABLE table_name ADD INDEX index_name (column_list)
ALTER TABLE table_name ADD UNIQUE (column_list)
ALTER TABLE table_name ADD PRIMARY KEY (column_list)
日常运维管理
-
查询表的大小
MariaDB [(none)]>select sum(DATA_LENGTH)+sum(INDEX_LENGTH) from information_schema.tables where table_schema='数据库名'; -
查询数据库默认字符集
MariaDB [(none)]> SHOW VARIABLES LIKE 'character%';
MariaDB [(none)]> SHOW VARIABLES LIKE 'collation_%';