$ mysql -u root -p
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.21-log MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> select * from firstapp_article;
+----+------------------------+----------------------------------+-------------+-------------+-------+-----------+
| id | title | content | create_time | like_counts | score | author_id |
+----+------------------------+----------------------------------+-------------+-------------+-------+-----------+
| 1 | 来试试看 | asdsf | 2018-05-08 | 3 | 6.1 | NULL |
| 3 | OK, Lets try it again | 按时到家乐福及水电费垃圾堆上两个 | 2018-05-08 | 0 | 1.1 | NULL |
+----+------------------------+----------------------------------+-------------+-------------+-------+-----------+
2 rows in set (0.01 sec)
mysql>
#查询数据表的字段信息
mysql> describe firstapp_article;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(100) | NO | | NULL | |
| content | longtext | YES | | NULL | |
| create_time | date | NO | | NULL | |
| like_counts | int(11) | NO | | NULL | |
| score | double | NO | | NULL | |
| author_id | int(11) | YES | MUL | NULL | |
+-------------+--------------+------+-----+---------+----------------+
7 rows in set (0.01 sec)
mysql>
CREATE USER 用户名@'允许IP' IDENTIFIED BY '密码'
mysql> CREATE USER marco@'localhost' IDENTIFIED BY 'root';
Query OK, 0 rows affected (0.04 sec)
mysql>
//开放所有权限给marco用户,可以这样来写:
mysql> GRANT ALL PRIVILEGES ON 数据库.数据表 TO marco@localhost;
//刷新系统权限表。
mysql>flush privileges;
//如果想指定部分权限(select,update)给marco用户,可以这样来写:
mysql>grant select,update on phplampDB.* to marco@localhost;
//刷新系统权限表。
mysql>flush privileges;
mysql> GRANT ALL PRIVILEGES ON *.* TO marco@localhost;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> DELETE FROM user WHERE User="marco" and Host="localhost";
mysql>flush privileges;
//删除用户的数据库
mysql>drop database 数据库;