1.改密码5.7后操作
1.1 alter改密码
mysql> alter user root@localhost identified by '1';
Query OK, 0 rows affected (0.00 sec)
1.2 update改密码
mysql5.7后user表下的password字段改为了authentication_string
mysql> update mysql.user set authentication_string=password('1') where user='root';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
1.3 set修改密码
mysql> set password for root@localhost=password('1');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
1.4 mysqladmin修改密码
1.4.1 root没有密码
假如你的root没有密码,你希望将密码改成123456,执行
mysqladmin -u root password
1.4.2 root有密码
假如你的root有密码,你希望将密码改成123456,执行:
mysqladmin -u root -p password
2.库管理命令
- show databases;
- use 库名;
- select database();
- create database 库名;
- show tables;
- drop database 库名;
3.表管理命令
-
新建表
create table 库名.表名( 字段名1 字段类型(宽度) 约束条件, 字段名2 字段类型(宽度) 约束条件, 字段名N 字段类型(宽度) 约束条件 )
mysql> create table test.study1( -> name char(20), -> age int);
-
表
- desc 表名;
- select * from 表名;
- drop table 表名;
-
记录管理命令
-
select * from 表名;
-
insert into 表名 values(值列表);
mysql> insert into study1 values('liuneng',21),('zhaosi',22);
-
update 表名 set 字段=值;
mysql> update study1 set age=30; #所有人的age都改为30 mysql> update study1 set age=25 where name='huanhuan'; #将huanhuan的age改为25
-
delete from 表名;
mysql> delete from study1 where name='zhaosi'; #删除zhaosi的记录 mysql> delete from study1; #删除表中所有的记录
-