PS C:\Users\蔡> mysql -u root -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 8.0.12 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.
登入root账户
mysql> create database vsearchlogdb;
Query OK, 1 row affected (0.02 sec)
mysql> create user 'search'@'localhost' identified by 'vsearchpasswd';
Query OK, 0 rows affected (0.03 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'search'@'localhost' with grant option;
Query OK, 0 rows affected (0.15 sec)
mysql> quit
Bye
创建名为vsearchlogdb的库
创建本地用户search和密码vsearchpasswd
授予本地用户所有的权限
退出
PS C:\Users\蔡> mysql -u search -p
Enter password: *************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 26
Server version: 8.0.12 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.
进入search账户
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sakila |
| sys |
| vsearchlogdb |
| world |
+--------------------+
7 rows in set (0.00 sec)
展示数据库
mysql> use vsearchlogdb
Database changed
使用vsearchlogdb数据库
mysql> create table log (id int(11) auto_increment primary key, ts timestamp default current_timestamp not null, phrase varchar(128)not null,letters varchar(32) not null, ip varchar(16) not null, browser_string varchar(256) not null,results varchar(64) not null);
Query OK, 0 rows affected (0.20 sec)
创建一个表
mysql> describe log;
+----------------+--------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+-------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| ts | timestamp | NO | | CURRENT_TIMESTAMP | |
| phrase | varchar(128) | NO | | NULL | |
| letters | varchar(32) | NO | | NULL | |
| ip | varchar(16) | NO | | NULL | |
| browser_string | varchar(256) | NO | | NULL | |
| results | varchar(64) | NO | | NULL | |
+----------------+--------------+------+-----+-------------------+----------------+
7 rows in set (0.00 sec)
展示这个表