mysql6.5安装过程,MySQL5.7安装过程填坑记(Centos 6.5)

最近想安装5.7.18 MySQL Community Server 来玩一玩,但安装复杂了好多,尤其在为root用户设置密码这块,就是不能设置简单的123456,我只是测试学习,不需要为了安全弄个16位,32位的MD5码什么的,之前老版本5.5左右的只要下载安装server和client,但是世道变了...

一、系统自带mysql-lib(系统自带的版本过低)

查看系统自带的mysql,什么都没有的话就算了,跳过该步

rpm -qa | grep mysql

但是出现自带的mysql

mysql-libs-5.1.73-3.el6_5.x86_64```

卸载它

`yum remove mysql-libs`

## 二、rpm依赖关系

那么我们进入正题,首先是各个rpm安装包的**依赖关系**,很明显,新的5.7版本需要下载很多rpm,我直接下了个bundle

![mysql下载](http://upload-images.jianshu.io/upload_images/4072363-c00c42504ec212a5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

解压到centos6.5中 的/opt目录下,有这么多包:

![mysql的rpm集](http://upload-images.jianshu.io/upload_images/4072363-c32202074a40c9f3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/800)

怎么解压我就不细说了,重点是这里:

rpm -ivh mysql-community-common-5.7.18-1.el6.x86_64.rpm

rpm -ivh mysql-community-libs-5.7.18-1.el6.x86_64.rpm

rpm -ivh mysql-community-client-5.7.18-1.el6.x86_64.rpm

rpm -ivh mysql-community-server-5.7.18-1.el6.x86_64.rpm

依赖关系就是前面的要是没安装,后面的也否想安装,所以一定要按顺序,(倒是前两个可以互换,忘记吧,当我没说),按顺序,一定要按顺序。

## 三、修改密码(巨坑)

启动mysql 服务

`service mysqld start`

rpm安装mysql后,会自动初始化一个密码,在日志中,密码为:R!/kValB_3k+(安装后随机生成的,别指望这个能用,复制粘贴是没用滴)

[root@localhost ~]# cat /var/log/mysqld.log | more

2016-03-11T01:44:19.913630Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --ex

plicit_defaults_for_timestamp server option (see documentation for more details).

2016-03-11T01:44:22.271099Z 0 [Warning] InnoDB: New log files created, LSN=45790

2016-03-11T01:44:22.584299Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

2016-03-11T01:44:23.050146Z 0 [Warning] No existing UUID has been found, so we assume that this is the first

time that this server has been started. Generating a new UUID: c7bf1a6a-e72a-11e5-8737-000c29a05942.

2016-03-11T01:44:23.062259Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cann

ot be opened.

+++++++++++++++++++++++++++++++++++密码在这里+++++++++++++++++++++++++++++++++++++++++++++++++++++++

2016-03-11T01:44:23.093873Z 1 [Note] A temporary password is generated for root@localhost: R!/kValB_3k+

++++++++++++++++++++++++++++++++++密码在这里++++++++++++++++++++++++++++++++++++++++++++++++++++++

2016-03-11T01:44:28.470492Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --ex

plicit_defaults_for_timestamp server option (see documentation for more details).

2016-03-11T01:44:28.471726Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.11) starting as process 19672 ...

2016-03-11T01:44:28.626135Z 0 [Note] InnoDB: PUNCH HOLE support available

2016-03-11T01:44:28.626205Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins

2016-03-11T01:44:28.626220Z 0 [Note] InnoDB: Uses event mutexes

2016-03-11T01:44:28.626233Z 0 [Note] InnoDB: GCC builtin __sync_synchronize() is used for memory barrier

当然也可以这样获取

[root@cloud01 opt]# grep "password" /var/log/mysqld.log

2017-05-19T10:04:22.286192Z 1 [Note] A temporary password is generated for root@localhost: R!/kValB_3k+

修改 mysql root密码,由于最新的mysql版本对密码策略有要求,所以必须增加复杂程度才能通过

注意,用刚才的随机密码登陆mysql.

[root@localhost ~]# mysql -uroot -p

Enter password: 此处输入刚才日志文件中:R!/kValB_3k+

Welcome to the MySQL monitor. commands end with ; or \g.

Your MySQL connection id is 14

Server version: 5.7.11

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> set password='CodeGalileo@126.com';

Query OK, 0 rows affected (0.15 sec)

mysql> quit;

Bye

但是我只想设置123456为密码,方便自己使用,那么就会这样,

mysql> SET PASSWORD = PASSWORD('123456');

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

解决方案:(想知道为什么,参见这位大神http://www.cnblogs.com/ivictor/p/5142809.html)

mysql> set global validate_password_policy=0;

Query OK, 0 rows affected (0.00 sec)

mysql> set global validate_password_length=6;

Query OK, 0 rows affected (0.00 sec)

接下来我就可以设置我超级简单的密码了

mysql> SET PASSWORD=PASSWORD('123456');

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

设置密码的坑就算填了。

【注意】

我们以前启动mysql-server后经常这么设置密码:

mysql -u root password '123456'

**相信我,有时候,就算你登录了mysql,你也建不出表,查询不了,那么你就需要这个方案来改改密码**

## 四、远程连接

默认情况下,mysql只允许locathost本地登陆,用mysql workbentch ,或者JDBC是无法远程登陆的。

root@localhost,代表root只允许本地用户登陆,

所以必须允许root 从任何IP地址登陆。

`mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';`

当然要关闭Linux防火墙

## 五、开机自启

有人会为了练习敲指令的速度,会在每次开机的时候,手动启动mysql-server,我就不会,这事忘了怎么办?

开机自启这样做:

chkconfig mysqld on

## 六、卸载mysql

![卸载顺序.png](http://upload-images.jianshu.io/upload_images/4072363-000cbd5c3ee16595.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

清除残留:

find / -name "mysql

rm -rf /var/lib/mysql

rm -rf /usr/share/mysql;

rpm -qa | grep mysql

至此,我在安装新版的5.7.18MySQL Community 过程中遇到的坑,算是踩一个填一个,没错,我都踩了...

**欢迎大家补充,共同努力降低初学者学习mysql的门槛**

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值