MySQL 基本操作詳解

2021-10-04 13:58:54 字數 1373 閱讀 2875

create

database table_name;

create

table

ifnot

exists

`userinfo`

(`id`

intunsigned

auto_increment

,`username`

varchar

(100

)not

null

,`password`

varchar(40

)not

null

,`email`

varchar(40

),`token`

varchar

(100),

primary

key(

`id`))

engine

=innodb

default

charset

=utf8;

insert

into userinfo (username, password, email)

values

("admin"

,"admin"

,"[email protected]"

);

drop

table table_name;

若報 error 1051 (42s02): unknown table 『xx.xx』,請仔細檢查資料表的名稱有沒有寫正確。

delete

from userinfo where 欄位1

="xx"

and 欄位1=2

;

如果有主鍵,則直接利用主鍵確定某一行。

查詢表的所有記錄:

select

*from userinfo;

查詢表中滿足要求的記錄:

select

*from userinfo where username=

"xx"

and password=

"xx"

;

update userinfo set token=

"nksd5mhw"

where username=

"admin"

;

net start mysql

net stop mysql

mysql -u root -p

show databases;

use 資料庫名;

mysql基本操作 MySQL基本操作

mysql中新增使用者,新建資料庫,使用者授權,刪除使用者,修改密碼 注意每行後邊都跟個 表示乙個命令語句結束 1.新建使用者 1.1 登入mysql mysql u root p 密碼 1.2 建立使用者 mysql insert into mysql.user host,user,passwor...

mysql 基本操作 mysql基本操作

mysql 建立表,並設定主鍵自增 create table log logid int 4 primary key not null auto increment,logtitle varchar 32 not null logcontent varchar 160 not null logtim...

MySQL 操作詳解

建立並選擇資料庫 mysql show databases mysql create database test mysql use test建立表 mysql create table pet name varchar 20 owner varchar 20 species varchar 20 ...