天天看点

Linux下mysql数据库基本操作

​<code>​mysql5.7后user表下的password字段改为了authentication_string​</code>​

Linux下mysql数据库基本操作

假如你的root没有密码,你希望将密码改成123456,执行

Linux下mysql数据库基本操作

假如你的root有密码,你希望将密码改成123456,执行:

Linux下mysql数据库基本操作

show databases;

use 库名;

select database();

create database 库名;

show tables;

drop database 库名;

新建表

<code>create table 库名.表名( 字段名1 字段类型(宽度) 约束条件, 字段名2 字段类型(宽度) 约束条件, 字段名N 字段类型(宽度) 约束条件 )</code>

<code>mysql&gt; create table test.study1( -&gt; name char(20), -&gt; age int);</code>

desc 表名;

select * from 表名;

drop table 表名;

记录管理命令

insert into 表名 values(值列表);

<code>mysql&gt; insert into study1 values('liuneng',21),('zhaosi',22);</code>

update 表名 set 字段=值;

<code>mysql&gt; update study1 set age=30; #所有人的age都改为30 mysql&gt; update study1 set age=25 where name='huanhuan'; #将huanhuan的age改为25</code>

delete from 表名;

<code>mysql&gt; delete from study1 where name='zhaosi'; #删除zhaosi的记录 mysql&gt; delete from study1; #删除表中所有的记录</code>

继续阅读