Pré-requisitos
- Certifique-se de que você tem privilégios administrativos no seu Servidor Windows.
- Baixe a versão mais recente do MySQL Server.
Nesta instalação utilizaremos a versão 8.2 Innovation Community Server baixada de mysql.com
Passos de Instalação
01. Extrair os Arquivos do MySQLr
- Após baixar o arquivo zip do MySQL (por exemplo, mysql-8.2.0-winx64.zip), extrar o conteúdo para um diretório no seu sistema, como, por exemplo C:\MySQL.
02. Crie o Arquivo de Configuração
- Abra o bloco de notas e crie um arquivo chamado my.ini no diretório MySQL (C:\MySQL);
- Adicione o segunte texto
[mysqld]
port = 3306
basedir = C:\MySQL
datadir = C:\MySQL\DATA
sql_mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES, STRICT_ALL_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO
- Ajuste basedir e datadir conforme sua instalação
03. Inicie o serviço
- Pressione Win + X e selecione “Prompt de Comando (Admin)”
- Navegar até o diretório bim do MySQL: cd C:\MySQL\bin
- Execute a inicialização do MySQL (isto cria as tabelas de sistemas e o usuário root)
mysqld --initialize-insecure
Atenção: esta opção cria o usuário root sem senha
04. Instalar MySQL como Serviço
- Navegue até o diretório bin do MySQL no prompt de comando: cd C:\MySQL\bin
- Execute o seguinte comando para instalar o MySQL como um serviço:
mysqld install
05. Inicie o Serviço MySQL
Você pode iniciar o serviço Apache de duas maneiras diferentes
Iniciar Apache através da linha de comando
net start mysql
Iniciar Apache através do gerenciador de Serviços do Windows
- Pressione Win + R, digite services.msc, encontre “MySQL” na lista, clique com o botão direito e selecione “Iniciar”.
06. Proteja a instalação do MYSQL
Execute C:\MySQL\bin\>mysql_secure_installation, será exibido o passo-a-passo abaixo
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: Y
Please set the password for root here.
New password: ******************
Re-enter new password: ******************
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : N
... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.
All done!
C:\MySQL\bin>
07. Conecte ao MySQL usando a linha de comando
mysql -u root -p
Se vocẽ optou por --initialize-insecure, pressione enter quando for solicitada a senha
Importante
Executar MySQL pela linha de comando pode fornecer informações detalhadas sobre eventuais erros.
Acesse a pasta bin do MySQL (cd C:\MySQL\bin) e execute o comando:
mysql -u root -p
Observe se há erros de inicialização