Linux系統中:mysql進入的命令為mysql -u root -p +你的mysql密碼。 Mysql是如何添加用戶呢? 在mysql命令行下,使用use mysql;進入mysql的資料庫中。然後插入信息到user表,就可以添加上用戶了。 例子如下: 本人是根據無情站長的博客進行學習的,原創 ...
Linux系統中:mysql進入的命令為mysql -u root -p +你的mysql密碼。
Mysql是如何添加用戶呢?
在mysql命令行下,使用use mysql;進入mysql的資料庫中。然後插入信息到user表,就可以添加上用戶了。
例子如下:
MariaDB [mysql]> insert into user (host,user,password,select_priv,insert_priv,update_priv) values ('localhost','whr',password('whr123'),'Y','Y','Y'); Query OK, 1 row affected, 4 warnings (0.00 sec) MariaDB [mysql]> select host,user,password from user;
常用的管理Mysql的命令:
use 資料庫;(進入資料庫)
MariaDB [(none)]> use mysql;
Database changed
show databases;(查看MySQL中的所有資料庫)
MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.01 sec) show tables;(查看當前資料庫中的所有表) MariaDB [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 | +---------------------------+ 24 rows in set (0.00 sec) show columnns form 表名;(顯示指定表的屬性) MariaDB [mysql]> show columns from servers; +-------------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+----------+------+-----+---------+-------+ | Server_name | char(64) | NO | PRI | | | | Host | char(64) | NO | | | | | Db | char(64) | NO | | | | | Username | char(64) | NO | | | | | Password | char(64) | NO | | | | | Port | int(4) | NO | | 0 | | | Socket | char(64) | NO | | | | | Wrapper | char(64) | NO | | | | | Owner | char(64) | NO | | | | +-------------+----------+------+-----+---------+-------+ 9 rows in set (0.00 sec) show index from 表名;(顯示指定表的詳細索引信息,包括主鍵) MariaDB [mysql]> show index from user; +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ | user | 0 | PRIMARY | 1 | Host | A | NULL | NULL | NULL | | BTREE | | | | user | 0 | PRIMARY | 2 | User | A | 7 | NULL | NULL | | BTREE | | | +-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+ 2 rows in set (0.00 sec)
本人是根據無情站長的博客進行學習的,原創屬於無情站長,連接:https://www.cnblogs.com/skyhu365/p/10558216.html