Last active
August 29, 2015 14:14
-
-
Save iamfat/e94f0cd1ca8e569a950d to your computer and use it in GitHub Desktop.
Initialize MySQL when mapping container /var/lib/mysql to an empty directory in host.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run --rm -v /path/to/mysql/dir/in/host:/var/lib/mysql -it genee/mariadb bash | |
# IN THE TEMPORARY CONTAINER | |
export MYSQL_ROOT_PASS=83719730 | |
export MYSQL_GENEE_PASS=83719730 | |
mysql_install_db | |
/usr/sbin/mysqld --skip-networking & | |
sleep 3s | |
mysqladmin -u root password "$MYSQL_ROOT_PASS" | |
echo "GRANT ALL ON *.* TO genee@'%' IDENTIFIED BY '$MYSQL_GENEE_PASS' WITH GRANT OPTION; FLUSH PRIVILEGES" | mysql -u root -p"$MYSQL_ROOT_PASS" | |
# QUIT FROM THE TEMPORARY CONTAINER | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@pihizi @leejinlin 这个是初始化数据库的步骤..
其实主要是运行
mysql_install_db
后续那些都是为了配置root的密码, 同时给数据库增加一个可外网访问的genee用户