php - 如何为单个数据库设置auto_increment_offset和auto_increment_increment

标签 php mysql mysql-workbench mysql-error-1064

是否可以仅为单个数据库设置 auto_increment_offset 和 auto_increment_increment 变量而不影响任何其他数据库?

我想要这个的原因是我正在数据库上实现主主复制,但我有一个包含 30 个域及其数据库的云 VPS。所以我需要为单个数据库设置这个变量而不影响其他数据库。

最佳答案

不,它是一个全局变量。 You can set it per session不过,因此可以编写 PHP 软件来在每次打开数据库连接时设置它。

If the local value is set, the new value affects AUTO_INCREMENT columns for all tables into which new rows are inserted by the current user for the duration of the session, unless the values are changed during that session.

关于php - 如何为单个数据库设置auto_increment_offset和auto_increment_increment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24085336/

相关文章:

java - 限制 PHP -> Java Applet 的文件访问

php - 使用 php 在 mysql 中搜索逗号分隔值

mysql - 解决mysql查询

mysql - 如何记录/写入查询执行期间发生的错误和警告

php - Doctrine Fatal Error - 未知关系别名

javascript - 提交两个表单,其中 form2 输入值取决于 form1 输入值

php - 将所有内容重定向到 index.php

php - 销售发票表格

php - PDO mysql 查询类似数组值

MySQL 正向工程师 - SQL 给出错误 121