安装MySQL
sudo apt install mysql-server
sudo apt install mysql-client
sudo apt install libmysqlcliet-dev
修改mysql数据库user表root密码
use mysql;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
创建数据库
create database fugo;
查看数据库字符集
show variables like '%character%';
创建表
create table client (cid bigint(20) unsigned not null auto_increment, username varchar(30), phone_no varchar(11), primary key(cid));
添加表字段
alter table client add column password varchar(50) after phone_no;
更改字段类型
alter table client MODIFY password text;
插入数据
insert into client (username, phone_no) values ("lschen", "12345678901");
更新值(注意:MySQL新版本里已经删除了password函数,可直接用MD5函数或SHA1函数,这里用的是SHA1函数。)
update client set password=sha1("123456") where username = "lschen";
查找
select * from client where username = 'lschen';