账户管理
sentence | meaning |
---|
mysql -h IP(localhost) -u User-p Password | 登录 |
create user Name identified by ‘Password’ | 新建用户账户 |
grant select,insert,update,delete on .(test.*) to User@”%” identified by ‘Password’ | 授全表(test.*表)权限 |
set password for Name=password(‘Password’) | 改密 |
select user ,host from user | 查看所有账户(mysql库) |
select distinct user from mysql.user | 显示所有的用户(不重复) |
show grants for ‘User’@’Host’ | 查看用户权限 |
delete from user where user =”User” | 销户 |
一般情况下分配越少的账号越好管理,不得已需要分配多账号,也要限制其登陆主机为localhost
库表管理
sentence | meaning |
---|
show databases(tables) | 所有库(表) |
use Databasename | 选库 |
describe Tablename | 表结构 |
create(drop) database(table) Name | 建(销)库(表) |
rename database(table)Name to Name | 重命名 |
alter table Name change Old New 属性 | 改字段 |
alter table Name add new 属性 | 增字段 |