[root@mysql ~]
# mysql -uroot -p #再输入密码
2 Welcome to the MySQL monitor. Commands end with ;
or \g.
3 Your MySQL connection id
is 4
4 Server version: 5.5.49
MySQL Community Server (GPL)
5
6 Copyright (c) 2000, 2016, Oracle
and/
or its affiliates. All rights reserved.
7
8 Oracle
is a registered trademark of Oracle Corporation
and/
or its
9 affiliates. Other names may be trademarks of their respective
10 owners.
11
12 Type
‘help;‘ or ‘\h‘ for help. Type
‘\c‘ to clear the current input statement.
13
14
15 #创建数据库
16 mysql>
create database test1;
17 Query OK, 1 row affected (0.02
sec)
18
19
20 #进入test1库中
21 mysql>
use test1;
22 Database changed
23
24 #创建表tb1(nid和name字段)
25 mysql> create table tb1(nid int,name varchar(20
));
26 Query OK, 0 rows affected (0.06
sec)
27
28 #创建tb2 (nid和name字段)
29 mysql> create table tb2(nid int,name varchar(20
));
30 Query OK, 0 rows affected (0.01
sec)
31
32 #查看表
33 mysql>
show tables;
34 +-----------------+
35 | Tables_in_test1 |
36 +-----------------+
37 | tb1 |
38 | tb2 |
39 +-----------------+
40 2 rows
in set (0.01
sec)
41
42 #查看所有表
43 mysql> select *
from tb1;
44 Empty set (0.01
sec)
45
46 #往表中插入数据
47 mysql> insert into tb1(nid,name)values(1,
‘alex‘);
48 Query OK, 1 row affected (0.01
sec)
49
50 #往表中插入数据
51 mysql> insert into tb1(nid,name)values(1,
‘eric‘);
52 Query OK, 1 row affected (0.01
sec)
53
54 #查看所有表
55 mysql> select *
from tb1;
56 +------+------+
57 | nid | name |
58 +------+------+
59 | 1 | alex |
60 | 1 | eric |
61 +------+------+
62 2 rows
in set (0.00
sec)
63
64 #退出
65 mysql>
exit
66 Bye
二、用户授权
用户管理特殊命令:
创建用户
create user ‘用户名‘@‘IP地址‘ identified by ‘密码‘;
删除用户
drop user ‘用户名‘@‘IP地址‘;
修改用户
rename user ‘用户名‘@‘IP地址‘; to ‘新用户名‘@‘IP地址‘;;
修改密码
set password for ‘用户名‘@‘IP地址‘ = Password(‘新密码‘)
MySQL(一)
标签:res 修改 current span int creat 改密码 type register