一、mysql用户管理
--建立mysql用户帐户--
--登录mysql
mysql -h hostname -u username -p password;
mysql --host=localhost --user=root --password
--创建账户并授予数据库访问权限
grant all on dbname.* to 'username'@'hostname' identified by 'password';
--查看mysql帮助
mysql --help
二,mysql创建数据库表和样表
--创建数据库
create database dbname;
--切换当前使用数据库
use dbname;
--创建表
create table limbs (thing varchar(20), legs int, arms int);
--插入数据
insert into limbs(thing, legs, arms) values('human', 2, 2);
insert into limbs(thing, legs, arms) values('insect', 6, 0);
insert into limbs(thing, legs, arms) values('squid', 0, 10);
insert into limbs(thing, legs, arms) values('octopus', 0, 8);
insert into limbs(thing, legs, arms) values('fish', 0, 0);
insert into limbs(thing, legs, arms) values('centipede', 100, 0);
insert into limbs(thing, legs, arms) values('table', 4, 0);
insert into limbs(thing, legs, arms) values('armchair', 4, 2);
insert into limbs(thing, legs, arms) values('phonograph', 0, 1);
insert into limbs(thing, legs, arms) values('tripod', 3, 0);
insert into limbs(thing, legs, arms) values('Peg Leg Pete', 1, 2);
insert into limbs(thing, legs, arms) values('space alien', null, null);
--查询数据
select * from limbs;