diff --git a/keyserver/src/creators/session-creator.js b/keyserver/src/creators/session-creator.js
--- a/keyserver/src/creators/session-creator.js
+++ b/keyserver/src/creators/session-creator.js
@@ -3,6 +3,7 @@
 import type { CalendarQuery } from 'lib/types/entry-types';
 
 import { dbQuery, SQL } from '../database/database';
+import { getDBType } from '../database/db-config';
 import type { Viewer } from '../session/viewer';
 
 async function createSession(
@@ -24,11 +25,23 @@
     INSERT INTO sessions (id, user, cookie, query,
       creation_time, last_update, last_validated)
     VALUES ${[row]}
+  `;
+  const dbType = await getDBType();
+  if (dbType === 'mysql5.7') {
+    query.append(SQL`
     ON DUPLICATE KEY UPDATE
       query = VALUES(query),
       last_update = VALUES(last_update),
       last_validated = VALUES(last_validated)
-  `;
+    `);
+  } else {
+    query.append(SQL`
+    ON DUPLICATE KEY UPDATE
+      query = VALUE(query),
+      last_update = VALUE(last_update),
+      last_validated = VALUE(last_validated)
+    `);
+  }
   await dbQuery(query);
   viewer.setSessionInfo({
     lastValidated: time,
diff --git a/keyserver/src/updaters/account-updaters.js b/keyserver/src/updaters/account-updaters.js
--- a/keyserver/src/updaters/account-updaters.js
+++ b/keyserver/src/updaters/account-updaters.js
@@ -14,6 +14,7 @@
 
 import { createUpdates } from '../creators/update-creator';
 import { dbQuery, SQL } from '../database/database';
+import { getDBType } from '../database/db-config';
 import type { Viewer } from '../session/viewer';
 
 async function accountUpdater(
@@ -97,8 +98,17 @@
   const createOrUpdateSettingsQuery = SQL`
     INSERT INTO settings (user, name, data)
     VALUES ${[[viewer.id, request.name, request.data]]}
-    ON DUPLICATE KEY UPDATE data = VALUES(data)
   `;
+  const dbType = await getDBType();
+  if (dbType === 'mysql5.7') {
+    createOrUpdateSettingsQuery.append(SQL`
+    ON DUPLICATE KEY UPDATE data = VALUES(data)
+    `);
+  } else {
+    createOrUpdateSettingsQuery.append(SQL`
+    ON DUPLICATE KEY UPDATE data = VALUE(data)
+    `);
+  }
 
   await dbQuery(createOrUpdateSettingsQuery);
 }
diff --git a/keyserver/src/updaters/activity-updaters.js b/keyserver/src/updaters/activity-updaters.js
--- a/keyserver/src/updaters/activity-updaters.js
+++ b/keyserver/src/updaters/activity-updaters.js
@@ -18,6 +18,7 @@
 
 import { createUpdates } from '../creators/update-creator';
 import { dbQuery, SQL, mergeOrConditions } from '../database/database';
+import { getDBType } from '../database/db-config';
 import type { SQLStatementType } from '../database/types';
 import { deleteActivityForViewerSession } from '../deleters/activity-deleters';
 import {
@@ -268,11 +269,21 @@
       threadID,
       time,
     ]);
-    await dbQuery(SQL`
+    const query = SQL`
       INSERT INTO focused (user, session, thread, time)
       VALUES ${focusedInsertRows}
+    `;
+    const dbType = await getDBType();
+    if (dbType === 'mysql5.7') {
+      query.append(SQL`
       ON DUPLICATE KEY UPDATE time = VALUES(time)
-    `);
+      `);
+    } else {
+      query.append(SQL`
+      ON DUPLICATE KEY UPDATE time = VALUE(time)
+      `);
+    }
+    await dbQuery(query);
   }
 
   if (viewer.hasSessionInfo) {
diff --git a/keyserver/src/updaters/relationship-updaters.js b/keyserver/src/updaters/relationship-updaters.js
--- a/keyserver/src/updaters/relationship-updaters.js
+++ b/keyserver/src/updaters/relationship-updaters.js
@@ -22,6 +22,7 @@
 import { createThread } from '../creators/thread-creator';
 import { createUpdates } from '../creators/update-creator';
 import { dbQuery, SQL, mergeOrConditions } from '../database/database';
+import { getDBType } from '../database/db-config';
 import { fetchFriendRequestRelationshipOperations } from '../fetchers/relationship-fetchers';
 import { fetchUserInfos } from '../fetchers/user-fetchers';
 import type { Viewer } from '../session/viewer';
@@ -37,7 +38,10 @@
   }
 
   const uniqueUserIDs = [...new Set(request.userIDs)];
-  const users = await fetchUserInfos(uniqueUserIDs);
+  const [users, dbType] = await Promise.all([
+    fetchUserInfos(uniqueUserIDs),
+    getDBType(),
+  ]);
 
   let errors = {};
   const userIDs: string[] = [];
@@ -121,8 +125,16 @@
       const directedInsertQuery = SQL`
         INSERT INTO relationships_directed (user1, user2, status)
         VALUES ${directedInsertRows}
-        ON DUPLICATE KEY UPDATE status = VALUES(status)
       `;
+      if (dbType === 'mysql5.7') {
+        directedInsertQuery.append(SQL`
+        ON DUPLICATE KEY UPDATE status = VALUES(status)
+        `);
+      } else {
+        directedInsertQuery.append(SQL`
+        ON DUPLICATE KEY UPDATE status = VALUE(status)
+        `);
+      }
       promises.push(dbQuery(directedInsertQuery));
     }
     if (directedDeleteIDs.length) {
@@ -174,8 +186,16 @@
     const directedInsertQuery = SQL`
       INSERT INTO relationships_directed (user1, user2, status)
       VALUES ${directedRows}
-      ON DUPLICATE KEY UPDATE status = VALUES(status)
     `;
+    if (dbType === 'mysql5.7') {
+      directedInsertQuery.append(SQL`
+      ON DUPLICATE KEY UPDATE status = VALUES(status)
+      `);
+    } else {
+      directedInsertQuery.append(SQL`
+      ON DUPLICATE KEY UPDATE status = VALUE(status)
+      `);
+    }
     const directedDeleteQuery = SQL`
       DELETE FROM relationships_directed
       WHERE status = ${directedStatus.PENDING_FRIEND} AND 
@@ -242,12 +262,24 @@
     INSERT INTO relationships_undirected (user1, user2, status)
     VALUES ${rows}
   `;
+
+  const dbType = await getDBType();
   if (greatest) {
-    query.append(
-      SQL`ON DUPLICATE KEY UPDATE status = GREATEST(status, VALUES(status))`,
-    );
+    if (dbType === 'mysql5.7') {
+      query.append(
+        SQL`ON DUPLICATE KEY UPDATE status = GREATEST(status, VALUES(status))`,
+      );
+    } else {
+      query.append(
+        SQL`ON DUPLICATE KEY UPDATE status = GREATEST(status, VALUE(status))`,
+      );
+    }
   } else {
-    query.append(SQL`ON DUPLICATE KEY UPDATE status = VALUES(status)`);
+    if (dbType === 'mysql5.7') {
+      query.append(SQL`ON DUPLICATE KEY UPDATE status = VALUES(status)`);
+    } else {
+      query.append(SQL`ON DUPLICATE KEY UPDATE status = VALUE(status)`);
+    }
   }
   await dbQuery(query);
 }
@@ -278,7 +310,10 @@
   }
   selectQuery.append(mergeOrConditions(conditions));
 
-  const [result] = await dbQuery(selectQuery);
+  const [[result], dbType] = await Promise.all([
+    dbQuery(selectQuery),
+    getDBType(),
+  ]);
   const existingStatuses = new Map();
   for (const row of result) {
     existingStatuses.set(`${row.user1}|${row.user2}`, row.status);
@@ -297,8 +332,16 @@
   const insertQuery = SQL`
     INSERT INTO relationships_undirected (user1, user2, status)
     VALUES ${insertRows}
-    ON DUPLICATE KEY UPDATE status = GREATEST(status, VALUES(status))
   `;
+  if (dbType === 'mysql5.7') {
+    insertQuery.append(SQL`
+    ON DUPLICATE KEY UPDATE status = GREATEST(status, VALUES(status))
+    `);
+  } else {
+    insertQuery.append(SQL`
+    ON DUPLICATE KEY UPDATE status = GREATEST(status, VALUE(status))
+    `);
+  }
   await dbQuery(insertQuery);
 
   return updateDatasForUserPairs(
diff --git a/keyserver/src/updaters/thread-permission-updaters.js b/keyserver/src/updaters/thread-permission-updaters.js
--- a/keyserver/src/updaters/thread-permission-updaters.js
+++ b/keyserver/src/updaters/thread-permission-updaters.js
@@ -955,12 +955,16 @@
   // column and this is an INSERT, but we don't want to require people to have
   // to know the current `subscription` when they're just using this function to
   // update the permissions of an existing membership row.
+  const dbType = await getDBType();
   while (insertRows.length > 0) {
     const batch = insertRows.splice(0, membershipInsertBatchSize);
     const query = SQL`
       INSERT INTO memberships (user, thread, role, creation_time, subscription,
         permissions, permissions_for_children, last_message, last_read_message)
       VALUES ${batch}
+    `;
+    if (dbType === 'mysql5.7') {
+      query.append(SQL`
       ON DUPLICATE KEY UPDATE
         subscription = IF(
           (role <= 0 AND VALUES(role) > 0)
@@ -971,7 +975,21 @@
         role = VALUES(role),
         permissions = VALUES(permissions),
         permissions_for_children = VALUES(permissions_for_children)
-    `;
+      `);
+    } else {
+      query.append(SQL`
+      ON DUPLICATE KEY UPDATE
+        subscription = IF(
+          (role <= 0 AND VALUE(role) > 0)
+            OR (role > 0 AND VALUE(role) <= 0),
+          VALUE(subscription),
+          subscription
+        ),
+        role = VALUE(role),
+        permissions = VALUE(permissions),
+        permissions_for_children = VALUE(permissions_for_children)
+      `);
+    }
     await dbQuery(query);
   }
 }