安装数据库:
mysqld install
mysql的启停与连接:
# 启动mysql
net start mysql
# 停止mysql
net stop mysql
# 客户端连接mysql(root用户)
mysql -uroot -p
创建用户:
CREATE USER 'dev'@'%' IDENTIFIED BY 'dev';
查看用户名和密码:
use mysql;
select user,host,authentication_string from user;
修改密码:
update mysql.user set authentication_string=password('123456') where user='yyy' ;
创建库表,
create database dataBaseName character set utf8;//创建数据库
drop database dataBaseName;//删除数据库
create table tableName
(
columnName typle,
...
);//建表
drop table tableName;//删表
对库和表的操作:
use databaseName;//选择数据库
show databases; //显示所有的库
show tables;//显示库中所有的表,要先use 选中数据库
show create table tableName;//查看表结构
show index from tableName;//显示数据表的详细索引信息,包括PRIMARY KEY(主键)。
quit/exit;//退出mysql
修改表结构:
alter table tableName old_name rename new_name; --修改表名
alter table tableName add column add_name varchar(10) after/first column; --添加表列(在已有字段后/前)
alter table tableName drop column del_name; --删除表列
alter table tableName modify address char(10) --修改表列类型
alter table tableName change column address address1 varchar(30)--修改表列名
对数据基本增删改查:
use dataBaseName;
insert into table(columnName,..) values (values,...);//插入数据
delete from tableName where columnName = 'where';//删除
update tableName where columnName = 'where' set columnName = 'value'
select * from runoob_tbl where username like '%wugui';//查询