mysql 日常使用

启动
windows 1 net start mysql 2 X:\installpath\bin\mysqld -u root (Enter)
linux 1 service mysqld start 2 service mysql start 3 /etc/inint.d/mysqld start
停止
windows 1 net stop mysql 2 mysqladmin -u root [-p password]
linux 1 service mysqld stop 2 /etc/inint.d/mysqld stop 3 mysqladmin shutdown
重启
linux 1 service mysqld restart 2 service mysql restart 3 /etc/init.d/mysqld restart
登录
mysql -h host -u user -p 回车 password
创建用户
1 create user 'username'@'host' [IDENTIFIED BY 'password'](不写为空密码);
  host 1localhost本地(默认) 2指定主机(ip) 3任意地方(%)
2 insert into mysql.user(Host,User,Password) values("localhost","test",password("1234"));
删除用户

1 drop user user@host
2 Delete FROM user Where User='test' and Host='host';
用户授权
grant 授权
all privileges 所有权限,可以单独给[select,delete,update,create,drop]
on DB(指定DB或者*所有DB).*(表) 
to root@localhost 用户@访问主机
identified by 'pass' 密码
刷新权限
flush privileges 刷新系统权限表

优化
1 字段类型为varchar有索引, sql中使用int查询用不到索引,反之字段属性为int有索引,sql查询用"字符串"可以用到索引
2 where条件中用到了联合索引,但联合索引里没有排序字段,order by索引用不到(严重影响速度),如果排序字段为多个不是同方向排序也可能用不上索引
3 like 时左边%时索引失效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值