No artigo de hoje quero demonstrar como instalar o MySQL Community Server 5.7 em sistemas baseados em RHEL. No meu caso estou utilizando Oracle E. Linux 6.7.
Vamos instalar via RPM, para isso, vamos baixar utilizando um dos links abaixo:
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
https://dev.mysql.com/downloads/mysql/
Antes de instalar os pacotes do MySQL que baixamos vamos verificar se há alguma outra instalação do MySQL Database Server no nosso servidor:
[root@mysql-master ~]# rpm -qa | grep mysql mysql-libs-5.1.73-8.0.1.el6_8.x86_64
Em nosso servidor existe o mysql-libs da versão 5.1.73 e este pode conflitar com a instalação do MySQL Database Server 5.7 que iremos instalar. Remova com o comando abaixo:
[root@mysql-master ~]# yum erase mysql-libs-5.1.73-8.0.1.el6_8.x86_64 Loaded plugins: refresh-packagekit, security, ulninfo Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package mysql-libs.x86_64 0:5.1.73-8.0.1.el6_8 will be erased --> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64 --> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-6.el6_7.1.x86_64 --> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_7.1.x86_64 --> Running transaction check ---> Package postfix.x86_64 2:2.6.6-6.el6_7.1 will be erased --> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-16.el6_8.2.x86_64 --> Processing Dependency: /usr/sbin/sendmail for package: redhat-lsb-core-4.0-7.0.2.el6.x86_64 --> Running transaction check ---> Package cronie.x86_64 0:1.4.4-16.el6_8.2 will be erased --> Processing Dependency: cronie = 1.4.4-16.el6_8.2 for package: cronie-anacron-1.4.4-16.el6_8.2.x86_64 ---> Package redhat-lsb-core.x86_64 0:4.0-7.0.2.el6 will be erased --> Processing Dependency: redhat-lsb-core(x86-64) = 4.0 for package: redhat-lsb-graphics-4.0-7.0.2.el6.x86_64 --> Processing Dependency: redhat-lsb-core(x86-64) = 4.0-7.0.2.el6 for package: redhat-lsb-4.0-7.0.2.el6.x86_64 --> Processing Dependency: redhat-lsb-core(x86-64) = 4.0 for package: redhat-lsb-printing-4.0-7.0.2.el6.x86_64 --> Running transaction check ---> Package cronie-anacron.x86_64 0:1.4.4-16.el6_8.2 will be erased ---> Package redhat-lsb.x86_64 0:4.0-7.0.2.el6 will be erased --> Processing Dependency: redhat-lsb(x86-64) = 4.0-7.0.2.el6 for package: redhat-lsb-compat-4.0-7.0.2.el6.x86_64 ---> Package redhat-lsb-graphics.x86_64 0:4.0-7.0.2.el6 will be erased ---> Package redhat-lsb-printing.x86_64 0:4.0-7.0.2.el6 will be erased --> Running transaction check ---> Package redhat-lsb-compat.x86_64 0:4.0-7.0.2.el6 will be erased --> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch --> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-31.el6.x86_64 --> Restarting Dependency Resolution with new changes. --> Running transaction check ---> Package crontabs.noarch 0:1.10-33.el6 will be erased ---> Package sysstat.x86_64 0:9.0.4-31.el6 will be erased --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Removing: mysql-libs x86_64 5.1.73-8.0.1.el6_8 @public_ol6_latest 4.0 M Removing for dependencies: cronie x86_64 1.4.4-16.el6_8.2 @public_ol6_latest 174 k cronie-anacron x86_64 1.4.4-16.el6_8.2 @public_ol6_latest 43 k crontabs noarch 1.10-33.el6 @anaconda-OracleLinuxServer-201311252058.x86_64/6.5 2.4 k postfix x86_64 2:2.6.6-6.el6_7.1 @public_ol6_latest 9.7 M redhat-lsb x86_64 4.0-7.0.2.el6 @public_ol6_latest 0.0 redhat-lsb-compat x86_64 4.0-7.0.2.el6 @public_ol6_latest 0.0 redhat-lsb-core x86_64 4.0-7.0.2.el6 @public_ol6_latest 22 k redhat-lsb-graphics x86_64 4.0-7.0.2.el6 @public_ol6_latest 0.0 redhat-lsb-printing x86_64 4.0-7.0.2.el6 @public_ol6_latest 0.0 sysstat x86_64 9.0.4-31.el6 @public_ol6_latest 826 k Transaction Summary ======================================================================================================================================================================== Remove 11 Package(s) Installed size: 15 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : redhat-lsb-4.0-7.0.2.el6.x86_64 1/11 Erasing : redhat-lsb-compat-4.0-7.0.2.el6.x86_64 2/11 Erasing : redhat-lsb-graphics-4.0-7.0.2.el6.x86_64 3/11 Erasing : redhat-lsb-printing-4.0-7.0.2.el6.x86_64 4/11 Erasing : redhat-lsb-core-4.0-7.0.2.el6.x86_64 5/11 /var/tmp/rpm-tmp.1Cn3Sf: line 1: lsb_release: command not found Erasing : sysstat-9.0.4-31.el6.x86_64 6/11 Erasing : cronie-1.4.4-16.el6_8.2.x86_64 7/11 Erasing : cronie-anacron-1.4.4-16.el6_8.2.x86_64 8/11 Erasing : crontabs-1.10-33.el6.noarch 9/11 Erasing : 2:postfix-2.6.6-6.el6_7.1.x86_64 10/11 Erasing : mysql-libs-5.1.73-8.0.1.el6_8.x86_64 11/11 Verifying : cronie-anacron-1.4.4-16.el6_8.2.x86_64 1/11 Verifying : redhat-lsb-printing-4.0-7.0.2.el6.x86_64 2/11 Verifying : cronie-1.4.4-16.el6_8.2.x86_64 3/11 Verifying : redhat-lsb-compat-4.0-7.0.2.el6.x86_64 4/11 Verifying : redhat-lsb-core-4.0-7.0.2.el6.x86_64 5/11 Verifying : crontabs-1.10-33.el6.noarch 6/11 Verifying : sysstat-9.0.4-31.el6.x86_64 7/11 Verifying : 2:postfix-2.6.6-6.el6_7.1.x86_64 8/11 Verifying : redhat-lsb-graphics-4.0-7.0.2.el6.x86_64 9/11 Verifying : mysql-libs-5.1.73-8.0.1.el6_8.x86_64 10/11 Verifying : redhat-lsb-4.0-7.0.2.el6.x86_64 11/11 Removed: mysql-libs.x86_64 0:5.1.73-8.0.1.el6_8 Dependency Removed: cronie.x86_64 0:1.4.4-16.el6_8.2 cronie-anacron.x86_64 0:1.4.4-16.el6_8.2 crontabs.noarch 0:1.10-33.el6 postfix.x86_64 2:2.6.6-6.el6_7.1 redhat-lsb.x86_64 0:4.0-7.0.2.el6 redhat-lsb-compat.x86_64 0:4.0-7.0.2.el6 redhat-lsb-core.x86_64 0:4.0-7.0.2.el6 redhat-lsb-graphics.x86_64 0:4.0-7.0.2.el6 redhat-lsb-printing.x86_64 0:4.0-7.0.2.el6 sysstat.x86_64 0:9.0.4-31.el6 Complete! [root@mysql-master ~]#
Certo, agora descompacte o arquivo tar baixado e veja os arquivos extraídos:
[root@mysql-master Downloads]# tar -xf mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar [root@mysql-master Downloads]# ls -lh total 897M -rw-r--r--. 1 root root 449M Feb 18 19:41 mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar -rw-r--r--. 1 7155 31415 23M Nov 29 14:29 mysql-community-client-5.7.17-1.el6.x86_64.rpm -rw-r--r--. 1 7155 31415 328K Nov 29 14:29 mysql-community-common-5.7.17-1.el6.x86_64.rpm -rw-r--r--. 1 7155 31415 3.6M Nov 29 14:29 mysql-community-devel-5.7.17-1.el6.x86_64.rpm -rw-r--r--. 1 7155 31415 38M Nov 29 14:29 mysql-community-embedded-5.7.17-1.el6.x86_64.rpm -rw-r--r--. 1 7155 31415 130M Nov 29 14:30 mysql-community-embedded-devel-5.7.17-1.el6.x86_64.rpm -rw-r--r--. 1 7155 31415 2.1M Nov 29 14:30 mysql-community-libs-5.7.17-1.el6.x86_64.rpm -rw-r--r--. 1 7155 31415 1.7M Nov 29 14:30 mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm -rw-r--r--. 1 7155 31415 152M Nov 29 14:31 mysql-community-server-5.7.17-1.el6.x86_64.rpm -rw-r--r--. 1 7155 31415 100M Nov 29 14:32 mysql-community-test-5.7.17-1.el6.x86_64.rpm [root@mysql-master Downloads]#
Veja na imagem abaixo algumas informações sobre os pacotes listados acima:
Agora sim, vamos instalar os pacotes necessários para o MySQL 5.7, conforme abaixo:
[root@mysql-master Downloads]# rpm -ivh mysql-community-common-5.7.17-1.el6.x86_64.rpm warning: mysql-community-common-5.7.17-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:mysql-community-common ########################################### [100%] [root@mysql-master Downloads]# [root@mysql-master Downloads]# rpm -ivh mysql-community-libs-5.7.17-1.el6.x86_64.rpm warning: mysql-community-libs-5.7.17-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:mysql-community-libs ########################################### [100%] [root@mysql-master Downloads]# [root@mysql-master Downloads]# rpm -ivh mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm warning: mysql-community-libs-compat-5.7.17-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:mysql-community-libs-co########################################### [100%] [root@mysql-master Downloads]# rpm -ivh mysql-community-client-5.7.17-1.el6.x86_64.rpm warning: mysql-community-client-5.7.17-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:mysql-community-client ########################################### [100%] [root@mysql-master Downloads]# [root@mysql-master Downloads]# rpm -ivh mysql-community-server-5.7.17-1.el6.x86_64.rpm warning: mysql-community-server-5.7.17-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY Preparing... ########################################### [100%] 1:mysql-community-server ########################################### [100%] [root@mysql-master Downloads]#
Tudo certo, agora inicie o mysql:
[root@mysql-master /]# service mysqld start Initializing MySQL database: [ OK ] Installing validate password plugin: [ OK ] Starting mysqld: [ OK ] [root@mysql-master /]#
No arquivo: mysqld.log encontramos os logs de erros que ocorrem no MySql:
[root@mysql-master ~]# tail -f /var/log/mysqld.log 2017-02-19T12:59:17.829159Z 0 [Note] Event Scheduler: Loaded 0 events 2017-02-19T12:59:17.829364Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. 2017-02-19T12:59:17.829383Z 0 [Note] Beginning of list of non-natively partitioned tables 2017-02-19T12:59:18.113736Z 0 [Note] End of list of non-natively partitioned tables 2017-02-19T12:59:18.113878Z 0 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.7.17' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server (GPL) 2017-02-19T12:59:18.253268Z 3 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO) 2017-02-19T16:49:51.145540Z 4 [Note] Access denied for user 'UNKNOWN_MYSQL_USER'@'localhost' (using password: NO) 2017-02-19T17:13:44.373115Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO) 2017-02-19T17:19:16.644130Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO)
Configure o MySQL para iniciar automaticamente no boot do servidor:
[root@mysql-master ~]# chkconfig mysqld on [root@mysql-master ~]# chkconfig --list mysqld mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Se você não estiver com o firewall parado, insira uma exceção para que a porta 3306 do MySQL esteja liberada para acesso externo, como por exemplo o MySQL Workbench:
[root@mysql-master ~]# service iptables status Table: filter Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) num target prot opt source destination 1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) num target prot opt source destination [root@mysql-master ~]# [root@mysql-master ~]# iptables -I INPUT -p tcp -m tcp --dport 3306 -j ACCEPT [root@mysql-master ~]# service iptables save iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] [root@mysql-master ~]# service iptables status Table: filter Chain INPUT (policy ACCEPT) num target prot opt source destination 1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306 2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 3 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0 4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) num target prot opt source destination 1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) num target prot opt source destination [root@mysql-master ~]#
Após a instalação do MySQL (se você não fizer nada), o usuário padrão será o “root” e a senha será vazia. Agora quero deixar uma dica. Se por acaso você tomar o erro abaixo ao tentar se conectar no banco ou ao alterar a senha:
ERROR 1045: Access denied for user: ' root@localhost' (Using password: NO)
Abaixo uma solução alternativa:
1. Pare o MySQL:
[root@mysql-master ~]# /etc/init.d/mysqld stop Stopping mysqld: [ OK ]
2. Iniciei o MySQL, sem senha:
[root@mysql-master ~]# mysqld_safe --skip-grant-tables 2017-02-19T18:03:10.000381Z mysqld_safe Logging to '/var/log/mysqld.log'. 2017-02-19T18:03:10.004182Z mysqld_safe Logging to '/var/log/mysqld.log'. 2017-02-19T18:03:10.032501Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
3. Conecte ao MySQL, usando:
[root@mysql-master /]# mysql mysql -u root Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 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.
4. No prompt do MySQL, execute:
mysql> use mysql Database changed mysql> update user set password=PASSWORD("mysql123") where User='root'; ERROR 1054 (42S22): Unknown column 'password' in 'field list' mysql> update user set authentication_string=password('mysql123') where user='root'; Query OK, 1 row affected, 1 warning (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> quit Bye
5. Pare e inicie novamente o MySQL:
[root@mysql-master /]# /etc/init.d/mysqld stop Stopping mysqld: [ OK ] [root@mysql-master /]# /etc/init.d/mysqld start Starting mysqld: [ OK ]
6. Faça o teste:
[root@mysql-master ~]# mysql -u root -pmysql123 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 4 Server version: 5.7.17 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>
7. Redefina a senha do root com uma possível melhor política de segurança:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('Mysql*123'); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec) mysql> quit Bye
Abraço,
Ronaldo
Fontes:https://dev.mysql.com/doc/refman/5.7/en/linux-installation-rpm.html
Nenhum comentário:
Postar um comentário