mac下MySQL修改root初始密码
2016-03-08 22:56
651 查看
新装的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了。
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- Seafile Server本地权限提升漏洞(CVE-2014-5443)
- 从USB安装Ubuntu Server 10.04.3 图文详解
- MySQL 备份和恢复策略
- 什么是Mac OS X?跟Linux有什么区别
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)