1.输入 mysqld --initialize --console【可以看到随机生成的密码】 (直接使用 mysqld --initialize-insecure 这样可以初始化root用户密码为空,不需要加 shared-memory skip-grant-tables )
(如果输入 mysqld --initialize 看不到随机密码 就需要开放 shared-memory skip-grant-tables)
2.输入mysqld --console
3.打卡另一个窗口输入 mysql -uroot
4. 输入 flush privileges;(需要先刷新权限,不然报错The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement)
5. 设置密码 alter user'root'@'localhost' IDENTIFIED BY 'zlc@123';
6. 操作完成删除my.ini文件中的shared-memory,skip-grant-tables 重启服务
解释
skip-grant-tables
上面表示第一次登陆root没有密码 需要安全模式
shared-memory
上面 加上这个 mysqld --console 才能启动 不然报错(TCP/IP, --shared-memory, or --named-pipe should be configured on NT OS)
本文没有注册服务通过 mysqld --console 打开服务
常用命令
1.添加用户
create user 'zlc'@'localhost' identified by 'zlc@123';
2.用户授权
grant select, insert on database.* to 'zlc'@'localhost';
3.创建用户同时授权
grant all privileges on database.* to 'zlc'@'localhost' identified by 'zlc@123'; flush privileges;//刷新权限
4.删除用户
drop user 'zlc'@'localhost';
5.查看存储过程
select * from mysql.proc where db = 'zlc' and `type` = 'PROCEDURE'\G