Change mysql password in Docker container

前端 未结 3 1168
温柔的废话
温柔的废话 2021-02-02 14:10

How could I change root password in docker container since the container stop automatically once I stop the mysql service.

Should I stop the mysql container and deploy

3条回答
  •  醉话见心
    2021-02-02 14:31

    First go to docker container bash using

    docker exec -it containerId bash

    Then

    • To Set the new mysql password

      mysqladmin -u root -p'oldpassword' password 'newpassword'

    • To set the password empty use

      mysqladmin -u root -p'oldpassword' password ''

    Make sure there is no space between -p and oldpassword

提交回复
热议问题