MAC 环境下初始化mysql root 密码

1. 关掉mysql服务,打开系统设置最后的mysql,然后将mysql先关掉



2. 生成一个文件命名mysql-init,文件中放入:一句话,这句话不同版本不一样,如下:(括号里面不包含)


alter user ‘root’@‘localhost’ identified by ‘新密码’;(MySQL 5.7.6 and later)

set password for ‘root’@‘localhost’=password(‘新密码’);(MySQL 5.7.5 and earlier)



3. cd /usr/local/mysql/bin/


sudo su

mysqld_safe —init-file=/home/me/mysql-init &

mysqld_safe —skip-grant-tables &

./mysql


flush privileges;

update mysql.user  set authentication_string = password(‘你在文件中定义的新密码’),password_expired = ’N’ where user = ‘root’ and host = ‘localhost’;


flush privileges;

quit;


./mysql -u root -p


输入你的新密码就好了


参考:B.5.3.2.2 Resetting the Root Password: Unix and Unix-Like Systems小节(http://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html)


声明:本站所有文章和图片,如无特殊说明,均为原创发布,转载请注明出处。
随机推荐
JavaScript 修改 CSS 样式
JavaScript 代码混淆加密工具 javascript-obfuscator
JavaScript 工作者线程
WordPress RESTful API 的授权方式
WordPress 文章页作者信息 get_the_author() 和 get_the_author_meta()
Git push 错误:Updates were rejected because the remote contains work that you do not have locally
WordPress 添加自定义接口
WP_REST_Response 返回结果类