ZhangZhihui's Blog  

 

Copied from: https://dev.mysql.com/doc/refman/8.4/en/server-system-variables.html#sysvar_autocommit

 

6.2.2.2 Using Option Files

Most MySQL programs can read startup options from option files (sometimes called configuration files). Option files provide a convenient way to specify commonly used options so that they need not be entered on the command line each time you run a program.

To determine whether a program reads option files, invoke it with the --help option. (For mysqld, use --verbose and --help.) If the program reads option files, the help message indicates which files it looks for and which option groups it recognizes.

Note

A MySQL program started with the --no-defaults option reads no option files other than .mylogin.cnf.

A server started with the persisted_globals_load system variable disabled does not read mysqld-auto.cnf.

Many option files are plain text files, created using any text editor. The exceptions are:

 

Copief from: https://dev.mysql.com/doc/refman/8.4/en/option-files.html

 

mysql> SET PERSIST autocommit=0;
Query OK, 0 rows affected (0.00 sec)

 

mysql> SELECT * FROM user;
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
| id | name        | email                  | hashed_password                                              | created             |
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
|  3 | ZhangZhihui | ZhangZhihuiAAA@126.com | $2a$12$uTPD9RGtk4nt4rfS6yBF9.GcbV2vM0K557CdhJtEcwpCt1u5QQvp. | 2024-09-06 08:33:02 |
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
1 row in set (0.00 sec)

mysql> UPDATE user SET id = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT * FROM user;
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
| id | name        | email                  | hashed_password                                              | created             |
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
|  1 | ZhangZhihui | ZhangZhihuiAAA@126.com | $2a$12$uTPD9RGtk4nt4rfS6yBF9.GcbV2vM0K557CdhJtEcwpCt1u5QQvp. | 2024-09-06 08:33:02 |
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
1 row in set (0.00 sec)

mysql> ROLLBACK;
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT * FROM user;
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
| id | name        | email                  | hashed_password                                              | created             |
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
|  3 | ZhangZhihui | ZhangZhihuiAAA@126.com | $2a$12$uTPD9RGtk4nt4rfS6yBF9.GcbV2vM0K557CdhJtEcwpCt1u5QQvp. | 2024-09-06 08:33:02 |
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
1 row in set (0.00 sec)

mysql> 

 

mysql> UPDATE user SET id = 1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> exit;
Bye
zzh@ZZHPC:~$ docker exec -it mysql mysql -uroot -prootpwd
mysql> USE snippetbox;
Database changed
mysql> SELECT * FROM user;
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
| id | name        | email                  | hashed_password                                              | created             |
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
|  3 | ZhangZhihui | ZhangZhihuiAAA@126.com | $2a$12$uTPD9RGtk4nt4rfS6yBF9.GcbV2vM0K557CdhJtEcwpCt1u5QQvp. | 2024-09-06 08:33:02 |
+----+-------------+------------------------+--------------------------------------------------------------+---------------------+
1 row in set (0.00 sec)

mysql> 

 

posted on 2024-09-07 10:31  ZhangZhihuiAAA  阅读(13)  评论(0编辑  收藏  举报