mac mysql Access denied for user问题有效解决方法
2016-05-02 16:57
585 查看
可能有些读者在安装完 mysql 之后出现以下错误提示:
mysql > UPDATE mysql.user SET Password=PASSWORD('1234') WHERE User='root';[/code]
Query OK, 1 row affected, 1 warning (0.01 sec)Rows matched: 1 Changed: 1 Warnings: 1[/code]如未成功请参看【补充】5)
Your MySQL connection id is 3
Server version: 5.7.12 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.看到上述信息,就表明成功用 root 登陆 mysql。【补充】也许不同版本 mysql.user 栏目名称会有不同,如果上述 4)命令报错:ERROR 1054 (42S22): Unknown column 'password' in 'field list'
那么就更改命令为:mysql> update mysql.user set authentication_string=password('1234') where user='root';[/code]
mysql -uroot -p Enter password:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)这是 mysql 在 linux 系统下的一个小缺陷,未给出 root 密码,导致初次无法登陆。这里给出 mysql 密码修改的有效方案,该方案在5.7.12亲测有效:0) 在用户目录下输入以下命令:
touch bashrc sudo chmod +w bashrc sudo vi /etc/bashrc在bashrc的末尾增加以下两个命令别名,便于快速使用mysql
alias mysql='/usr/local/mysql/bin/mysql' alias mysqladmin='/usr/local/mysql/bin/mysqladmin'1) 停止 mysql 服务
sudo /usr/local/mysql/support-files/mysql.server stop2) 在安全模式下启动 mysql
sudo mysqld_safe --skip-grant-tables3) 新建一个命令窗口(可在当前窗口下按快捷键command+N创建):
mysql -u root4) 在命令窗口下修改命令
mysql > UPDATE mysql.user SET Password=PASSWORD('1234') WHERE User='root';[/code]
Query OK, 1 row affected, 1 warning (0.01 sec)Rows matched: 1 Changed: 1 Warnings: 1[/code]如未成功请参看【补充】5)
mysql > FLUSH PRIVILEGES;6) 新建命令窗口,用密码1234再尝试登陆
mysql -uroot -p Enter password:Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.12 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.看到上述信息,就表明成功用 root 登陆 mysql。【补充】也许不同版本 mysql.user 栏目名称会有不同,如果上述 4)命令报错:ERROR 1054 (42S22): Unknown column 'password' in 'field list'
那么就更改命令为:mysql> update mysql.user set authentication_string=password('1234') where user='root';[/code]
相关文章推荐
- MySQL和Lucene索引对比分析
- ubuntu mysql5.6 数据库占用CPU过高导致机器卡死
- servlet向jsp传递值,mysql服务器报错
- mysql简单语句学习
- mysql 5.7.12 winx64安装配置方法图文教程
- Mac的mysql出现Table 'AAA' is marked as crashed and should be repaired
- 安装mysql-5.7.12-winx64
- 最新mysql5.7.12 win64 安装及配置
- mysql大页内存的使用
- MySQL索引原理
- mysql磁盘设置
- mysql:数据表的基本操作
- Mysql---学习笔记<二>
- MySQL事务提交过程(二)
- MySQL事务提交过程(一)
- MySQL 基本操作
- mysql查询缓存
- MySQL与PostgreSQL
- 爬取京东本周热卖商品所有用户评价存入MySQL
- 跟我一起学习MySQL技术内幕(第五版):(第二章学习日记13)