linux下MySQL5.7.18安装过程

原创 2018-01-18 11:22 阅读(1888)次

话说MySQL5.7是之前所有版本都无法比的(好像是废话啊,不然人家更新干嘛),可以说是一个跨时代版本(大家都这么说)。它主要对半同步复制技术多线程复制、主从数据一致性都进行了优化,我主要是奔着这些升级来的,不想再用5.6了。目前我已经把5.7用到我负责开发的网站中了,主要用来主从复制当备份数据库。

下载地址:http://downloads.mysql.com/archives/community/

也可以在https://dev.mysql.com/downloads/file/?id=469480页面中直接下载

环境:CentOS release 6.5 (Final)

MySQL:mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar

注意:下载好后,与5.6.2安装步骤一样,只有初始密码生成的方式不样,安装完后需要启动数据库,它才会自动初始化数据库并生成随机密码在/var/log/mysqld.log中

安装过程:

1.rpm -qa|grep mysql -i 检查是否有安装mysql
  mysql-libs-5.1.71-1.el6.x86_64
2.rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64卸载上面检查出来的包
3.tar -xvf mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar 解压下载好的rpm包,会出现下列9个rpm包
  mysql-community-common-5.7.18-1.el6.x86_64.rpm
  mysql-community-libs-5.7.18-1.el6.x86_64.rpm
  mysql-community-server-5.7.18-1.el6.x86_64.rpm
  mysql-community-client-5.7.18-1.el6.x86_64.rpm
  ......
4.依次安装下列四个包即可,否则会有依赖关系
  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
  有时安装server时会报 :
  error: Failed dependencies:
libnuma.so.1()(64bit) is needed by mysql-community-server-5.7.18-1.el6.x86_64
libnuma.so.1(libnuma_1.1)(64bit) is needed by mysql-community-server-5.7.18-1.el6.x86_64
libnuma.so.1(libnuma_1.2)(64bit) is needed by mysql-community-server-5.7.18-1.el6.x86_64
  安装yum install numactl,并且重装server就可以了
5.service mysqld start启动数据库,它会自动初始化数据库并生成随机密码在cat /var/log/mysqld.log中查看
  备注:不过我在我的虚拟机里安装时却是把日志打印出来的,里面有句密码生成可以看到,但是mysqld.log中什么都没有。可能是因为我之前安装过mysql,没卸载干净,老的/etc/my.cnf或者/usr/my.cnf影响到了数据库初始化
6.[root@search198 temp]# cat /var/log/mysqld.log

2017-05-08T06:06:16.603037Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-05-08T06:06:18.066941Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-05-08T06:06:18.450263Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-05-08T06:06:18.608686Z 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: 73af4946-33b4-11e7-8656-782bcb32f3c1.
2017-05-08T06:06:18.619755Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-05-08T06:06:18.620713Z 1 [Note] A temporary password is generated for root@localhost: o._>n1eX5&Mr

7.登录数据库并修改随机密码,必须修改
  mysql -u root -p o._>n1eX5&Mr
  SET PASSWORD = PASSWORD('password'); 密码必须包含数字,小写或大写,特殊字符,否则会报错
  GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

注意mysql 5.7与之前的版本启动关闭时用的服务名是mysqld
service mysqld start

service mysqld stop


linux下MySQL5.6.2安装过程