(6) MySQL operation under Docker

1. Check the mirror information corresponding to mysql

docker images


2. Start the mysql process

method one:

sudo docker run -d -p 3306:3306 -v/home/mysql:/mysql e0062635ad5d

Note: /home/mysql:/mysql is assigned to the corresponding directory to expand the storage space

 

Method Two:

sudo docker run -d -p 3306:3306 ggk_mysql:latest

Note: mysql : latest is the REPOSITORY and TAG values ​​in the corresponding mysql mirror information column respectively

 

3. Enter into mysql

(1) Enter the container operation: docker exec -ti a88 /bin/bash Note: the container id corresponding to a88

(2) Log in to mysql: mysql -uroot -p1 Note: 1 indicates the root password

(3) Exit mysql: exit

(4) Exit the container: exit

 

4. Modify the root password of mysql

mysql> use mysql; connect permission database

mysql> update user setpassword=password('kaiyuan@test') where user='root'; change password

mysql> flush privileges; flush privileges

 

5. Modify mysql time

1. Log in to mysql

mysql -uroot -pkaiyuan@test

2. Modify the mysql global time zone to Beijing time, which is the East 8th district where we are located

set global time_zone = '+8:00';

3. Modify the current session time zone

set time_zone = '+8:00';

4. #Effective immediately

flushprivileges;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325516560&siteId=291194637