mysql李筆記 mysql操作筆記

2021-10-20 23:20:18 字數 2400 閱讀 5133

匯出資料庫

mysqldump -u root -p -r presentation > presentation.sql

匯出presentation資料庫中users表

mysqldump -u root -p presentation users > presentation.sql

匯入資料庫

mysql -u root -p presentation 

或者先建立資料庫create databse presentation;

然後執行

use presentation

source presentation.sql

修改密碼

mysql -u root mysql

update user set password=password('newpassword') where user='root';

flush privileges;

create table users(

-> id int not null auto_increment,

-> username varchar(100) character set utf8 not null,

-> department varchar(100) character set utf8 not null,

-> role_id int not null,

-> primary key ( id )

-> ) engine=innodb default charset=utf8;

create table roles(

-> id int not null auto_increment,

-> rolename varchar(100) character set utf8 not null,

-> role_priv varchar(100) character set utf8 not null,

-> primary key ( id )

-> ) engine=innodb default charset=utf8;

create table audit(

-> id int not null auto_increment,

-> log_time varchar(50) character set utf8 not null,

-> log_user varchar(100) character set utf8 not null,

-> log_addr varchar(50) character set utf8 not null,

-> log_type varchar(50) character set utf8 not null,

-> log_detail varchar(1024) character set utf8 not null default 『』,

-> primary key ( id )

-> ) engine=innodb default charset=utf8;

解決中文插入保錯的問題

alter table users modify role_id int(11) not null default 0;

alter table users default character set utf8;

alter table users change department department varchar(100) character set utf8;

insert into users(username,department) values('xueyongda01','多維');

update users set role_id=2 where username='lixiang';

mysql -u root

show databases;

use 資料庫名;

show tables;

describe 表名;

建資料庫:create databse 庫名;

建表: create table 表名;

insert into name(uname,gender,birthday) values('張三','男','1971-10-01');

update name set birthday='1971-01-10' where uname='張三';

delete from name where uname='張三';

drop database 庫名;

insert into vast_op_log(log_time,log_user,log_addr,log_type,log_detail) values("2017-11-18 17:43:47","liushaojie","10.200.5.85","vast_api","/vast/api/nd/");

李福連的MySql筆記

1.安裝mysql installer community 8.0.19.0.msi 過程中設定root密碼 2.配置環境變數 3.常用語句有 1.開關服務 cd c program files mysql mysql server 8.0 bin 在bin下操作 mysqld console 開啟...

mysql操作筆記

user01只能本地訪問 create user user01 localhost identified by password1 user02可以遠端訪問 create user user02 identified by password1 建立資料庫 create database db01 修...

mysql操作筆記

一 select user 顯示的為當前使用的 user 及host use mysql select distinct user from user 顯示該資料庫授權登陸的使用者名稱 其實還有 host 的限制 mysql 中新增使用者 新建資料庫 使用者授權 刪除使用者 修改密碼 注意每行後邊都...