mac下MySQL修改root初始密码

        新装的mysql在登录时需要注意:

For example, if you run the server using the mysql login account, you should log in as mysql before using the instructions. Alternatively, you can log in as root, but in this case you must start mysqld with the --user=mysql option. If you start the server as root without using --user=mysql, the server may create root-owned files in the data directory, such as log files, and these may cause permission-related problems for future server startups.
(以上内容来自官方文档)

在使用root用户登录时,需要加上--user=mysql,否则服务器将会在数据目录下洗创建一个root-owned文件,这样在服务器启动的时候会引起权限问题。(未尝试--user=mysql,新装完mysql的同学可以尝试下)

        现在到这里,已经登录不了mysql了,要么是ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO),

要么是ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:  YES),现在如何做?

        在终端下输入:cd /usr/local/mysql/bin/

        使用管理员权限:sudo su

        回车后输入以下命令来禁止mysql验证功能

        ./mysqld_safe --skip-grant-tables &

        之后mysql会自动重启,完成之后打开mysql workbench,在Query窗口执行flush privileges,再执行set password for root='<your password>',执行完之后,就可以使用新的root密码来登录mysql了。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值