下载MysqL-server-5.6.33-1.rhel5.x86_64.rpm与MysqL-client-5.6.33-1.rhel5.x86_64.rpm
http://dev.mysql.com/downloads/file/?id=464994
http://dev.mysql.com/downloads/file/?id=465025
在/usr/local/src/下创建MysqL目录
[root@localhost src]# mkdir MysqL
将两个rpm文件拷贝到MysqL目录下,进行安装:
[root@localhost MysqL]# rpm -ivh MysqL-server-5.6.33-1.rhel5.x86_64.rpm
[root@localhost MysqL]# rpm -ivh MysqL-client-5.6.33-1.rhel5.x86_64.rpm
安装后,启动MysqL
[root@localhost MysqL]# /etc/init.d/MysqL start
Starting MysqL. [ OK ]
成功启动
[root@localhostbin]# MysqL -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:NO)
查看/root/.MysqL_secret文件,找到临时密码
[root@localhostbin]# cat /root/.MysqL_secret
# The random password set for the root user at Mon Oct 10 18:25:50 2016 (localtime): Li9uM0_VvslGmjt8
#The random password set for the root user at Mon Oct 10 18:53:29 2016 (localtime): EQnYTpOworiyqYm6
[root@localhostbin]# MysqL -u root -p EQnYTpOworiyqYm6##临时密码
Enterpassword:EQnYTpOworiyqYm6##临时密码
提示密码过期
处理方法:
打开/root/.MysqL_secret文件,添加一个随机密码:Abcd1234
[root@localhostbin]# sudo cat /root/.MysqL_secret
# The random password set for the root user at Mon Oct 10 18:25:50 2016 (localtime): Li9uM0_VvslGmjt8
#The random password set for the root user at Mon Oct 10 18:53:29 2016 (localtime): EQnYTpOworiyqYm6
Abcd1234
[root@localhost bin]# MysqL -uroot -p Abcd1234
Enter password:
ERROR 1049 (42000): Unknown database 'Abcd1234'
提示Abcd1234数据库不存在,果断将'Abcd1234'修改为'MysqL',保存退出
1.停止服务
[root@localhostbin]# /etc/init.d/MysqL stop
Shuttingdown MysqL.. [ OK ]
2.进入MysqLd_safe
[root@localhostbin]# MysqLd_safe --skip-grant-tables & ##屏幕打印下列信息
[1] 32329
[root@localhost bin]# 161010 19:47:50 MysqLd_safe Logging to'/var/lib/MysqL/localhost.localdomain.err'.
161010 19:47:50 MysqLd_safe Starting MysqLd daemon with databases from/var/lib/MysqL
//在此光标处输入如下命令:
//屏幕打印如下信息:
Readingtable information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcometo the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.6.33 MysqL Community Server (GPL)
Copyright(c) 2000,2016,Oracle and/or its affiliates. All rights reserved.
Oracleis 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.
MysqL>SELECT* FROM user; ##之后更新root用户的密码
MysqL>updateuser SET Password = PASSWORD('root') WHERE User = 'root';
MysqL>flushprivileges;
MysqL>exit;
4.再次使用root登录,密码root
[root@localhostbin]# MysqL -u root -p
Enterpassword:
Welcometo the MysqL monitor. Commands end with; or \g.
YourMysqL connection id is 8
Serverversion: 5.6.33 MysqL Community Server (GPL)
Copyright(c) 2000,Oracle and/or its affiliates. All rights reserved.
Oracleis 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.
原文链接:https://www.f2er.com/centos/380427.html