您的位置:首页 > 数据库 > MySQL

redhat EL6.5安装mysql5.7及常见问题

2017-06-15 10:29 525 查看

环境:

redhat EL 6.5

安装包下载:

mysql5.7下载

解压安装:

安装前先查看系统有没有安装mysql,有的话,就卸载掉

[root@server5 ~]# rpm -qa|grep mysql
mysql-libs-5.1.71-1.el6.x86_64
[root@server5 ~]#rpm -e mysql-libs-5.1.71-1.el6.x86_64 --nodeps


也可以不卸载,将包 mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm 也安装上,它会替换掉低版本的 libs 库

解压下载包:

[root@server5 ~]# tar -xf mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar


解压完:

[root@server5 ~]# ls
mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar
mysql-community-client-5.7.17-1.el6.x86_64.rpm
mysql-community-common-5.7.17-1.el6.x86_64.rpm
mysql-community-devel-5.7.17-1.el6.x86_64.rpm
mysql-community-embedded-5.7.17-1.el6.x86_64.rpm
mysql-community-embedded-devel-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-5.7.17-1.el6.x86_64.rpm
mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm
mysql-community-server-5.7.17-1.el6.x86_64.rpm
mysql-community-test-5.7.17-1.el6.x86_64.rpm


按顺序安装:

后一个包需要前面的依赖性

rpm -ivh mysql-community-common-5.7.17-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.17-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.17-1.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.17-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.17-1.el6.x86_64.rpm
#如果安装不了,需要依赖性,就用yum安装
#yum install -y mysql-community-server-5.7.17-1.el6.x86_64.rpm


启动:

/etc/init.d/mysqld start

与5.7之前的版本相比,5.7安装完之后是有一个自动生成的密码的

在日志文件 /var/log/mysqld.log 中

使用命令

cat /var/log/mysqld.log | grep temp


过滤一下就能得到密码

[root@server6 ~]# cat /var/log/mysqld.log | grep temp
2017-06-15T01:48:09.199189Z 1 [Note] A temporary password is generated for root@localhost: qf_c!Eev3pFH


我的默认密码是 qf_c!Eev3pFH

如果在看到密码之前日志文档被误删了,得不到密码,就要以安全方式登录,然后修改密码。

解决方法:

在配置文件里添加登陆不检测密码:

vim /etc/my.cnf

添加在最后一行

skip-grant-tables


重启服务,就能直接登陆了(不要密码登陆)

设置密码:

1.如果在日志文件里得到密码,就可以输入默认密码然后直接修改密码:

[root@server6 ~]# mysql_secure_installation


2.如果密码忘记了,.通过上面安全方式登陆的mysql,可以进行如下方式修改.

用户密码是在名为mysql的database下面

登进数据库,依次执行下列命令:

mysql> use mysql;
mysql> update user set password_expired='N' where user='root';
mysql> update user set authentication_string=password('redhat') where user='root';
mysql> flush privileges;


注意:

安全模式下设置完密码后,必须要把之前配置文件设置的跳过检测密码去掉,然后重启服务

自此,mysql5.7 就安装成功了.

测试:

登陆成功:

[root@server5 ~]# mysql -uroot -predhat
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.17 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.

mysql>
mysql> quit
Bye


mysql5.7设置了自动检测密码强度,已经设过的密码不能再使用,设的密码必须包括大小写,数字,特殊字符,长度必须大于等于8位.

不过可以更改密码强度(临时的,在退出数据库后,下次要设置简单密码,还要重新输入这几条命令,已经设置的永久生效):

如果要永久更改密码强壮度,要安装一个插件.

解决方法:

mysql> set global validate_password_policy=0;  #更改密码强度
mysql> <
a627
span class="hljs-built_in">set global validate_password_length=0;  #更改密码长度


改完之后,就行了:

mysql> GRANT REPLICATION SLAVE,RELOAD,SUPER ON *.* TO mysql@'172.25.12.5' IDENTIFIED BY 'redhat';
Query OK, 0 rows affected, 1 warning (0.31 sec)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql red hat