Skip to content

Instantly share code, notes, and snippets.

@iamfat
Last active August 29, 2015 14:14
Show Gist options
  • Save iamfat/e94f0cd1ca8e569a950d to your computer and use it in GitHub Desktop.
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.
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
@iamfat
Copy link
Author

iamfat commented Jan 26, 2015

@pihizi @leejinlin 这个是初始化数据库的步骤..
其实主要是运行mysql_install_db 后续那些都是为了配置root的密码, 同时给数据库增加一个可外网访问的genee用户

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment