Common application data access archive

2023-01-11   ES  

Guide to use mysql containers in Docker, and mapping through ports, and external access

Construct a container

docker run --name some-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
  • –name specified container name
  • -P parameters Map the 3306 port in the container with the local 3306 interface
  • -e adds an environment variable MySQL_ROOT_PASSWORD, which is defined as the root password

Configure external IP access permissions

The current database is already running in the container, but it is still unable to access the outside, because the access right of external IP needs to be configured;

docker exec -it hnister-mysql /bin/bash

Enter the container and configure mysql permissions

# Log in MySQL 
 MySQL -UROOT -PMY -SECRET -PW 
 # After entering, USE MySQL database: 
 mysql> use mysql; 

 # Add ROOT users can remotely access the end password to your external access password 
 MySQL> Grant All Privileges on*.* to 'root'@'%' identified by 'password';
mysql> update `mysql`.`user` set `Grant_priv` = 'Y' where `user` = 'root';
mysql> delete from user where user='root' and host='localhost';
mysql> flush privileges;

external access

source

Related Posts

linux process monitoring AI

Single plural conversion

Openark installation tutorial

MAC configuration Flutter development environment to the first Flutter App

Common application data access archive

Random Posts

java —— Elegant formulation a crawler API

IOS realizes directly jump and open positioning

cluster start command

qt configuration system new project function

Based on PostgreSQL and Postgis, Mars coordinate system, Baidu coordinate system, WGS84 coordinate system, CGCS2000 coordinate system