Mysql的管理
程序员文章站
2022-04-10 14:36:45
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)
本人是根据无情站长的博客进行学习的,原创属于无情站长,连接:
上一篇: Python操作MongoDB文档数据库
下一篇: 影响MySQL的性能(一)磁盘的选择