centos下安装mysql5.7后,强行修改mysql的root密码
来源:互联网 发布:淘宝默认几天自动付款 编辑:程序博客网 时间:2024/04/29 01:36
昨天在centos下安装mysql5.7后,却发现无法登陆,才新安装的mysql,初始密码应该没有,但是无论如何都无法登陆(提示密码错误),没办法,只好强行修改mysql密码。
输入
[root@localhost bin]# mysqld_safe --skip-grant-tables &
这句话相当于进入mysql的安全模式。
输入上面这条命令可能会出现错误如下:
[3] 7135[2] Exit 127 mysqld_stae --skip-grant-tables[root@localhost bin]# Usage: grep [OPTION]... PATTERN [FILE]...Try `grep --help' for more information.grep: write error: Broken pipe2016-04-02T10:16:02.306271Z mysqld_safe Logging to '/opt/mysql/data/localhost.localdomain.err'.2016-04-02T10:16:02.315564Z mysqld_safe The file /usr/local/mysql/bin/mysqlddoes not exist or is not executable. Please cd to the mysql installationdirectory and restart this script from there as follows:./bin/mysqld_safe&See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information[3]+ Exit 1 mysqld_safe --skip-grant-tables
根据错误提示在/usr/local下创建文件夹mysql/bin/mysqld
创建好文件夹后,准备开启mysql,但是在这之前先检查一下mysql是否开启
[root@localhost ~]# ps -ef|grep mysqld
如果开启使用kill -15 [pid]杀死mysql。如下:
[root@localhost ~]# ps -ef|grep mysqldroot 6946 1 0 18:15 ? 00:00:00 /bin/sh /opt/mysql/bin/mysqld_safe --datadir=/opt/mysql/data --pid-file=/opt/mysql/data/localhost.localdomain.pidmysql 7104 6946 0 18:15 ? 00:00:00 /opt/mysql/bin/mysqld --basedir=/opt/mysql --datadir=/opt/mysql/data --plugin-dir=/opt/mysql/lib/plugin --user=mysql --log-error=/opt/mysql/data/localhost.localdomain.err --pid-file=/opt/mysql/data/localhost.localdomain.pid --port=3306root 7558 7542 0 18:22 pts/0 00:00:00 grep mysqld[root@localhost ~]# kill -15 7104
再次使用 ps -ef|grep mysqld 确认mysql已经被杀死
开启mysql,如下:
[root@localhost ~]# mysqld_safe --skip-grant-tables &[1] 7566[root@localhost ~]# 2016-04-02T10:23:22.463266Z mysqld_safe Logging to '/opt/mysql/data/localhost.localdomain.err'.2016-04-02T10:23:22.514395Z mysqld_safe Starting mysqld daemon with databases from /opt/mysql/datamysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.11 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
修改mysql密码:注意!以前的password字段,在mysql5.7已经被改为了authentication_string。在password()函数里面输入你的新密码,记得加单引号哦。
mysql> UPDATE mysql.user SET authentication_string=password('YourPassword') WHERE User='root' AND Host='localhost';
好了,测试一下用新密码能不能进入:
[root@localhost ~]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.7.11Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
新密码修改成功!
一定要注意以前的password变成了authentication_string
0 0
- centos下安装mysql5.7后,强行修改mysql的root密码
- window下安装mysql后修改root账号的密码
- CentOS系统下强行重新修改MySQL密码
- CentOS 6.4下安装MySQL后重置root密码方法
- mac os 下安装好Mysql后无法连接(强行修改密码)
- Mac下 Mysql5.7忘记root密码及mysql5.7修改root密码的方法
- windows下mysql5.7忘记root密码后的解决方法
- CentOS 安装和配置 Mantis / Linux下修改Mysql的用户(root)的密码
- 在CentOS 6.3 64bit下yum安装MySQL后重置root密码的方法
- CentOS 安装mysql,并修改root密码
- mysql5.6及以上版本安装后修改root密码
- Mysql安装后修改root密码
- mysql安装后修改root密码
- mac mysql 安装后修改root密码
- mac下安装MySql,修改root密码,配置环境变量,设置默认字符集(mysql5.7.13)
- centos 下面修改mysql的root密码
- CentOS修改MySQL的root密码
- mysql5.7修改root密码
- 计算机的心智(二)进程
- 一些后台开发的基本问题(需要懂得)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(2)
- [POJ 1149]PIGS[最大流][建图]
- 结构型设计模式-适配器模式
- centos下安装mysql5.7后,强行修改mysql的root密码
- 从list删除元素
- 十个数输出!!!
- EFLAGS寄存器介绍
- 根据权重决定展示哪张图片的小算法(python+java)板砖
- POJ 1797 Heavy Transportation Dijstr最短路变形
- Makefile选项CFLAGS,LDFLAGS,LIBS
- 商业研究(8):汽车交通
- 2016郑州大学ACM/ICPC训练赛 Round4