Nota: Se você estiver atualizando o MySQL (de versão anterior para a mais atual), então certifique-se de que foi feito o backup(reserva e copiar) do seu banco de dados e das configurações. E lembre-se de executar mysql_upgrade comando.
1. Mude para usuário root
su - ## OR ## sudo -i
2. Instalando o repositório do MySQL
Fedora
## Fedora 23 ## dnf install https://dev.mysql.com/get/mysql57-community-release-fc23-7.noarch.rpm ## Fedora 22 ## dnf install https://dev.mysql.com/get/mysql57-community-release-fc22-7.noarch.rpm
3. Atualizando ou Instalando o MySQL 5.7.9
Fedora 23/22
dnf install mysql-community-server
4. Startando o MySQL server e habilitando para iniciar no boot
Fedora 23/22
systemctl start mysqld.service ## se estiver atualizando use o restart em vez de start systemctl enable mysqld.service
5. Gerando uma senha aleatória para o root
grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1
saída gerado para a senha aleatória:
1 [Note] A temporary password is generated for root@localhost: -et)QoL4MLid
E o password gerado é: -et)QoL4MLid
6. MySQL modo Instalação segura
- Mude a senha de root
- Remove o usuario anonymous
- Desabilite o login remoto do root
- Remove o database teste e o acesso dele
- Atualizar os privilegio das tabelas
Para iniciar a instalação do MySQL Secure siga as seguintes instruções
/usr/bin/mysql_secure_installation
Abrira o seguinte arquivo:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we\'ll need the current password for the root user. If you\'ve just installed MySQL, and you haven\'t set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): [ENTER YOUR RANDOM PASSWORD HERE] OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] Y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! 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? [Y/n] 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? [Y/n] Y ... Success! 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? [Y/n] 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? [Y/n] Y ... Success! Cleaning up... All done! If you\'ve completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!
Nota: Se você por alguma razão não quiser fazer a instalação do “MySQL secure”, pelo menos tenha um pouco de segurança, é muito importante mudar a senha do usuário root.
mysqladmin -u root password [your_password_here] ## Example ## mysqladmin -u root password myownsecrectpass
7. Conectando no MySQL (localhost)
mysql -u root -p ## OR ## mysql -h localhost -u root -p
Bem galera espero que esse tutorial lhes ajudem, qualquer duvida é só entrar em contato conosco nos comentários ou pelo email que esta logo mais no rodapé.