Diferencia entre revisiones de «Instalación MySQL»
Ir a la navegación
Ir a la búsqueda
([feat] Add information about Instalación MySQL) |
(feat: add SEO) |
||
(No se muestran 25 ediciones intermedias del mismo usuario) | |||
Línea 1: | Línea 1: | ||
== 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 run -p 3316:3306 --name=mysql-server5.7 -d mysql/mysql-server:5.7 mysqld --lower_case_table_names=1 | |||
Se genera un password | 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 |
Revisión actual - 09:08 26 nov 2024
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