1.创建用户命令:
<!---->mysql> CREATE USER yy IDENTIFIED BY '123';
yy表示你要建立的用户名,后面的123表示密码
上面建立的用户可以在任何地方登陆。
如果要限制在固定地址登陆,比如localhost 登陆:
<!---->mysql> CREATE USER yy@localhost IDENTIFIED BY '123';
2.授权grant:
<!---->mysql> GRANT ALL PRIVILEGES ON *.* TO user;@localhost
<!---->grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
格式:grant select on 数据库.* to 用户名@登录主机 identified by "密码"
修改密码:
<!---->mysql> grant all privileges on pureftpd.* to koko@localhost identified by 'mimi';
flush:
<!---->mysql> flush privileges;
查看用户信息:
<!---->mysql> select host,user from mysql.user;
3.删除用户。
@>mysql -u root -p
@>密码
mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost";
mysql>flush privileges;
//删除用户的数据库
mysql>drop database phplampDB;
@>mysql -u root -p
@>密码
mysql>DELETE FROM user WHERE User="phplamp" and Host="localhost";
mysql>flush privileges;
//删除用户的数据库
mysql>drop database phplampDB;
4.修改指定用户密码。
@>mysql -u root -p
@>密码
mysql>update mysql.user set password=password('新密码') where User="phplamp" and Host="localhost";
mysql>flush privileges;
5.列出所有数据库
mysql>show database;
6.切换数据库
mysql>use '数据库名';
7.列出所有表
mysql>show tables;
8.显示数据表结构
mysql>describe 表名;
9.删除数据库和数据表
mysql>drop database 数据库名;
mysql>drop table 数据表名;