(参考上面红色框定的部分,为方便你复制粘贴,再提供以下内容)
Enter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 18Server version: 8.0.22 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.#创建新的数据库,guacamole_db可以改成其他名称mysql> CREATE DATABASE guacamole_db;Query OK, 1 row affected (0.00 sec)#创建新的用户用于连接数据库,guacamole_user可以改成其他用户名,some_password为用户密码mysql> CREATE USER 'guacamole_user' IDENTIFIED BY 'some_password';Query OK, 0 rows affected (0.00 sec)#设置用户权限,注意 guacamole_db、guacamole_user要和上面的名称对应mysql> GRANT SELECT,INSERT,UPDATE,DELETE ON guacamole_db.* TO 'guacamole_user';Query OK, 0 rows affected (0.00 sec)#刷新权限mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.02 sec)#退出mysql> quitBye$
注意:上面命令每一条都有个分号,不要遗落。
# 新建的数据库需要初始化,guacamole/guacamole提供了脚本来生成初始化数据库
docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --mysql > initdb.sql
# 导入mysql,这里要注意在-p后面加上之前设置的密码my-secret-pw,实际操作中不带密码会报错
cat initdb.sql | docker run -i --link some-mysql --rm mysql mysql -hsome-mysql -uroot -pmy-secret-pw guacamole_db