Mysql操作

创建用户:

    create user 'username'@'host' identified by 'password';
本地用户:
    create user 'laosong'@'localhost' identified by '123'
具体用户:
    create user 'laosong01'@'172.16.2.11' identified by '123;
远程所有:
    create user 'laosong02'@'%' identified by '';

授权:

    GRANT privileges on databasename.tablename to 'username'@'host';
授予所有权限:
    GRANT ALL on *.* to 'laosong'@'localhost';
    GRANT INSERT,DELETE,UPDATE,SELECT ON test.user TO 'foo'@'localhost';
    flush privileges;
给用户授予可以授权的权限
    GRANT privileges on databasename.tablename to 'username'@'host' WITH GRANT OPTION

设置密码

    set password for 'username'@'host' =PASSWORD('password');
    update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";

撤销用户权限

    revoke privileges on databasename.tablename from 'username'@'host';

删除用户

    drop user 'username'@'host';

修改字段长度

    alter table tname modify column cname varchar(20);

修改字段类型

    alter table tname modify column cname char(20);

表中新增列

    alter table tname add column cname varchar(20);

表中修改列

    alter table tname change name name1 varchar(20) default '';

删除表中列

    alter table tname drop column cname;

你可能感兴趣的:(Mysql操作)