Diferencia entre revisiones de «Instalación MySQL»
Ir a la navegación
Ir a la búsqueda
(No se muestran 17 ediciones intermedias del mismo usuario) | |||
Línea 1: | Línea 1: | ||
= | = Instalación = | ||
== GNU/Linux == | == GNU/Linux == | ||
=== Docker === | === Docker === | ||
==== MySQL versión 8.0 ==== | |||
docker volume create mysql8.0-volume | |||
docker run -p 3326:3306 -v mysql8.0-volume:/var/lib/mysql --name=mysql-server8.0 -d mysql/mysql-server:8.0 mysqld --lower_case_table_names=1 | |||
Se genera un password | |||
docker logs mysql-server8.0 2>&1 | grep GENERATED | |||
Run container y acceder a la terminal MySQL: | |||
docker exec -it mysql-server8.0 mysql -uroot -p | |||
===== Cambiar pass del root ===== | |||
Cambiar pass del usuario root: | |||
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassGENERATED'; | |||
FLUSH PRIVILEGES; | |||
====== Observaciones ====== | |||
* En MyNewPassGENERATED debe de colocarse el password que se genero arriba. | |||
Run container y acceder al bash: | |||
docker exec -it mysql-server8.0 bash | |||
==== MySQL versión 5.7 ==== | ==== MySQL versión 5.7 ==== | ||
docker | docker run -p 3316:3306 --name=mysql-server5.7 -d mysql/mysql-server:5.7 mysqld --lower_case_table_names=1 | ||
Se genera un password | |||
docker logs mysql-server5.7 2>&1 | grep GENERATED | |||
Run container y acceder a la terminal MySQL: | |||
docker exec -it mysql-server5.7 mysql -uroot -p | |||
===== Cambiar pass del root ===== | |||
Cambiar pass del usuario root: | |||
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassGENERATED'; | |||
FLUSH PRIVILEGES; | |||
====== Observaciones ====== | |||
* En MyNewPassGENERATED debe de colocarse el password que se genero arriba. | |||
Run container: | Run container y acceder al bash: | ||
docker exec -it mysql-server5.7 bash | docker exec -it mysql-server5.7 bash | ||
==== MySQL versión 8.0 ==== | === Docker Compose === | ||
==== MySQL versión 8.0.32 ==== | |||
Archivo (docker-compose.yml) | |||
version: '3.8' | |||
services: | |||
db: | |||
image: mysql:8.0.32 | |||
command: | |||
--default-authentication-plugin=mysql_native_password | |||
restart: always | |||
environment: | |||
MYSQL_ROOT_PASSWORD: mysql | |||
ports: | |||
- "33306:3306" | |||
Levantar: | |||
docker compose up -d | |||
==== MySQL version 5.7.x ==== | |||
Archivo (docker-compose.yml) | |||
services: | |||
database: | |||
image: mysql:5.7 | |||
container_name: mysql | |||
restart: always | |||
environment: | |||
MYSQL_DATABASE: 'db' | |||
MYSQL_USER: 'user' | |||
MYSQL_PASSWORD: 'password' | |||
MYSQL_ROOT_PASSWORD: 'password' | |||
ports: | |||
- '3306:3306' | |||
expose: | |||
- '3306' | |||
volumes: | |||
- './.mysql-data/db:/var/lib/mysql' | |||
Levantar: | |||
docker compose up -d |
Revisión actual - 06:49 14 jun 2024
Instalación
GNU/Linux
Docker
MySQL versión 8.0
docker volume create mysql8.0-volume docker run -p 3326:3306 -v mysql8.0-volume:/var/lib/mysql --name=mysql-server8.0 -d mysql/mysql-server:8.0 mysqld --lower_case_table_names=1
Se genera un password
docker logs mysql-server8.0 2>&1 | grep GENERATED
Run container y acceder a la terminal MySQL:
docker exec -it mysql-server8.0 mysql -uroot -p
Cambiar pass del root
Cambiar pass del usuario root:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassGENERATED'; FLUSH PRIVILEGES;
Observaciones
- En MyNewPassGENERATED debe de colocarse el password que se genero arriba.
Run container y acceder al bash:
docker exec -it mysql-server8.0 bash
MySQL versión 5.7
docker run -p 3316:3306 --name=mysql-server5.7 -d mysql/mysql-server:5.7 mysqld --lower_case_table_names=1
Se genera un password
docker logs mysql-server5.7 2>&1 | grep GENERATED
Run container y acceder a la terminal MySQL:
docker exec -it mysql-server5.7 mysql -uroot -p
Cambiar pass del root
Cambiar pass del usuario root:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPassGENERATED'; FLUSH PRIVILEGES;
Observaciones
- En MyNewPassGENERATED debe de colocarse el password que se genero arriba.
Run container y acceder al bash:
docker exec -it mysql-server5.7 bash
Docker Compose
MySQL versión 8.0.32
Archivo (docker-compose.yml)
version: '3.8' services: db: image: mysql:8.0.32 command: --default-authentication-plugin=mysql_native_password restart: always environment: MYSQL_ROOT_PASSWORD: mysql ports: - "33306:3306"
Levantar:
docker compose up -d
MySQL version 5.7.x
Archivo (docker-compose.yml)
services: database: image: mysql:5.7 container_name: mysql restart: always environment: MYSQL_DATABASE: 'db' MYSQL_USER: 'user' MYSQL_PASSWORD: 'password' MYSQL_ROOT_PASSWORD: 'password' ports: - '3306:3306' expose: - '3306' volumes: - './.mysql-data/db:/var/lib/mysql'
Levantar:
docker compose up -d