1.忘记root密码
1.1 进入服务器找到my.cnf配置文件
在[mysqld]加入
skip-grant-tables
1.2 重启mysql
service mysqld restart
1.3 更新root密码
update user set authentication_string=password('要更新的密码') where user='root';
flush privileges;
2. 新建用户
格式:
create user '用户名'@'IP地址' identified by '密码';
如:
create user 'test1'@'%' identified by 'test1';
GRANT SELECT ON 数据库名.* TO '用户名'@'%';
3. 用户授权
格式:
grant 权限 on 数据库.表 to '用户'@'IP地址';
如:
grant all on *.* to 'test1'@'%' ;
4.删除用户
如:
drop user '用户名'@'IP地址';
5.修改用户
如:
rename user '用户名'@'IP地址'; to '新用户名'@'IP地址';
6 修改密码
如:
set password for '用户名'@'IP地址' = Password('新密码');
7.创建索引
CREATE INDEX 索引名 ON 表名 (索引字段);
建议索引名以idx_开头即 idx_ + 字段名
如:
CREATE INDEX idx_order_no ON t_order(order_no);
8. 删除索引
ALTER TABLE 表名DROP INDEX 索引名;
如
ALTER TABLE t_order DROP INDEX idx_order_no;
9.查询表的索引
show index FROM 表名;
如:
show index FROM t_order;
10.联合索引
ALTER TABLE t_order_list ADD INDEX idx_order_no_order_list_no (order_no,order_list_no);
11.查看数据库中表数据量最大
use information_schema;
select table_name,table_rows from tables WHERE table_name like 'jb%' order by table_rows desc limit 10;
持续更新.....