浏览代码

Reset SQL users, logs: info about tail

andryyy 8 年之前
父节点
当前提交
abcdf841cd
共有 1 个文件被更改,包括 47 次插入0 次删除
  1. 47 0
      docs/u_and_e.md

+ 47 - 0
docs/u_and_e.md

@@ -215,6 +215,51 @@ source mailcow.conf
 docker-compose exec mysql-mailcow mysql -u${DBUSER} -p${DBPASS} ${DBNAME} < backup_file.sql
 docker-compose exec mysql-mailcow mysql -u${DBUSER} -p${DBPASS} ${DBNAME} < backup_file.sql
 ```
 ```
 
 
+### Reset MySQL passwords
+
+Stop the stack by running `docker-compose stop`.
+
+When the containers came to a stop, run this command:
+
+```
+docker-compose run --rm --entrypoint '/bin/sh -c "gosu mysql mysqld --skip-grant-tables & sleep 10 && mysql -hlocalhost -uroot && exit 0"' mysql-mailcow
+```
+
+**1\. Find database name**
+
+```
+MariaDB [(none)]> show databases;
++--------------------+
+| Database           |
++--------------------+
+| information_schema |
+| mailcow_database   | <=====
+| mysql              |
+| performance_schema |
++--------------------+
+4 rows in set (0.00 sec)
+```
+
+**2\. Reset one or more users
+
+Both "password" and "authentication_string" exist. Currently "password" is used, but better set both.
+
+```
+MariaDB [(none)]> SELECT user FROM mysql.user;
++--------------+
+| user         |
++--------------+
+| mailcow_user | <===== 
+| root         |
++--------------+
+2 rows in set (0.00 sec)
+
+MariaDB [(none)]> FLUSH PRIVILEGES;
+MariaDB [(none)]> UPDATE mysql.user SET authentication_string = PASSWORD('gotr00t'), password = PASSWORD('gotr00t') WHERE User = 'root' AND Host = '%';
+MariaDB [(none)]> UPDATE mysql.user SET authentication_string = PASSWORD('mookuh'), password = PASSWORD('mookuh') WHERE User = 'mailcow' AND Host = '%';
+MariaDB [(none)]> FLUSH PRIVILEGES;
+```
+
 ## Debugging
 ## Debugging
 
 
 You can use `docker-compose logs $service-name` for all containers.
 You can use `docker-compose logs $service-name` for all containers.
@@ -223,6 +268,8 @@ Run `docker-compose logs` for all logs at once.
 
 
 Follow the log output by running docker-compose with `logs -f`.
 Follow the log output by running docker-compose with `logs -f`.
 
 
+Limit the output by calling logs with `--tail=300` like `docker-compose logs --tail=300 mysql-mailcow`.
+
 ## Redirect port 80 to 443
 ## Redirect port 80 to 443
 
 
 Since February the 28th 2017 mailcow does come with port 80 and 443 enabled.
 Since February the 28th 2017 mailcow does come with port 80 and 443 enabled.