CentOS5.5+MySQL5.6.33

来源:互联网 发布:新手怎么面试美工工作 编辑:程序博客网 时间:2024/06/06 01:45

下载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登录mysql

[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',保存退出

进行下列操作,修改root用户的密码

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
//在此光标处输入如下命令:

mysql--user root 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>##证明成功登录

3.修改root用户的密码

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, 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>   ##登录成功

0 0
原创粉丝点击