Skip to content

Instantly share code, notes, and snippets.

@carlosanders
Created July 23, 2018 16:40
Show Gist options
  • Select an option

  • Save carlosanders/52ac9682f9c1e051157ae4be30ff9803 to your computer and use it in GitHub Desktop.

Select an option

Save carlosanders/52ac9682f9c1e051157ae4be30ff9803 to your computer and use it in GitHub Desktop.
Passos para configurar acesso remoto do MySQL em servidores OEL7+

Configurando acesso remoto no MySQL OEL7+

  • Requisitos:
    • Ter o MySQL instalado no Servidor:

Editando o arquivo my.cnf

  1. Edite o arquivo my.cnf:
    • vim /etc/my.cnf
    • Adicione ao final do arquivo a seguinte linha: bind-address = *.
  2. Reinicie o servido do mysl:
    • service mysqld restart.

Criando um usuário para aceso em qualquer Host

  1. Acesse o mysql e crie o usuário:

    # entrando no mysql
    mysql -uroot -p<Senha-root-mysql>
    # adicione comando abaixo com a senha
    mysql> GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'senha_root';
    mysql> FLUSH PRIVILEGES;
    mysql> \q;

Testando o acesso via console remoto

  1. No console da maquina local, tente o acesse como o seguinte comando:

    # sintaxe:
    mysql -u USER -p<Senha-root-mysql> -P PORTA -h IP_DO_SERVER banco_db
    # Exemplo:
    mysql -u root -p -P 3306 -h 192.168.0.103 banco_db
    
    # ou de forma direta, mas insegura
    mysql -u root -p<Senha-root-mysql> -P 3306 -h 192.168.0.103 banco_db
    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.22 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2017, 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>

Até a próxima!

By Carlos Anders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment