Instalación del repositorio de MySQL
Instalación del repositorio en Fedora 32.
sudo dnf install -y sudo dnf install -y https://dev.mysql.com/get/mysql80-community-release-fc32-1.noarch.rpm
Instalar MySQL 8
sudo dnf install mysql-community-server
Iniciar MySQL 8
sudo systemctl start mysqld.service ## use restart after update sudo systemctl enable mysqld.service
Obtener la contraseña aleatoria generada automáticamente
Si solo van a actualizar MySQL, la contraseña a utilizar es la anterior que se usaba para root, si es una instalación nueva, entonces se obtiene de esta manera.
sudo grep 'A temporary password is generated for root@localhost' /var/log/mysqld.log |tail -1
Y la salida será parecida a esta:
2019-05-20T21:11:44.229891Z 1 [Note] A temporary password is generated for root@localhost: -et)QoL4MLid
Si por alguna razón no les da ninguna salida el comando, pueden buscar manualmente la contraseña, el archivo se encuentra en la ruta sudo gedit /var/log/mysqld.log
Instalación segura de MySQL
Ahora, es necesario realizar las siguientes configuraciones de MySQL:
- Cambiar la contraseña
- Eliminar usuarios anónimos
- Deshabilitar accesos remotos
- Eliminar bases de datos de prueba y sus accesos
- Recargar permisos de usuarios
Este proceso inicia con el siguiente comando:
su -
/usr/bin/mysql_secure_installation
Seguir los pasos del instructivo, así como se muestra en la salida de ejemplo siguiente:
Securing the MySQL server deployment. Enter password for user root: The existing password for the user account root has expired. Please set a new password. New password: Re-enter new password: VALIDATE PASSWORD PLUGIN 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 plugin? Press y|Y for Yes, any other key for No: y There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0 Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: Re-enter new password: Estimated strength of the password: 50 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y 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) : 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? (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!
Conectarse a localhost
En mi caso, iniciaremos con root, utilizando la contraseña que se haya establecido en los pasos de arriba, y cambiar el tipo de autenticación de MySQL.
A partir de la versión 5.7.x se agregó un nuevo método de autenticación que se llama caching_sha2_password, sin embargo, la configuración es un poco tediosa en linux para poderla utilizar con MySQL Workbench.
mysql -h localhost -u root -p
Esto iniciará el prompt de mysql:
Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 8 Server version: 8.0.4-rc-log MySQL Community Server (GPL) Copyright (c) 2000, 2018, 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>
Cambiar contraseña del usuario root y convertirlo a tipo por defecto de autenticación de mysql:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'nueva-o-la-misma-contraseña';
Agregar el servicio de MySQL el firewall:
firewall-cmd --permanent --zone=public --add-service=mysql ## ó ## firewall-cmd --permanent --zone=public --add-port=3306/tcp
Reinicia el servicio de MySQL:
systemctl restart firewalld.service
Instalación de MySQL Workbench
sudo dnf --disablerepo=* --enablerepo='mysql*-community*' list available
sudo dnf install mysql-workbench-community