• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

How to Fix MySQL Error 1228 – SQLSTATE: HY000 (ER_LOCAL_VARIABLE) Variable ‘%s’ is a SESSION variable and can’t be used with SET GLOBAL

December 20, 2023

How to Fix MySQL Error 1228 – SQLSTATE: HY000 (ER_LOCAL_VARIABLE)

MySQL is a popular open-source relational database management system used by many websites and applications. However, like any software, it can encounter errors that can disrupt its normal operation. One such error is MySQL Error 1228 – SQLSTATE: HY000 (ER_LOCAL_VARIABLE), which occurs when trying to use a session variable with the SET GLOBAL command. In this article, we will explore the causes of this error and provide solutions to fix it.

Understanding the Error

When you encounter MySQL Error 1228, you will see the following message:

Variable '%s' is a SESSION variable and can't be used with SET GLOBAL

This error occurs when you attempt to set a session variable using the SET GLOBAL command. Session variables are specific to a particular session and cannot be modified globally. The SET GLOBAL command is used to modify global system variables, which affect the entire MySQL server.

Possible Causes

There are several reasons why you might encounter MySQL Error 1228:

  • You are using the SET GLOBAL command instead of the SET SESSION command to modify a session variable.
  • You are trying to modify a session variable that is not allowed to be modified globally.
  • The session variable you are trying to modify does not exist.

Fixing MySQL Error 1228

To fix MySQL Error 1228, follow these steps:

1. Check the Variable

First, verify that the session variable you are trying to modify exists. You can do this by running the following command:

SHOW VARIABLES LIKE 'variable_name';

Replace ‘variable_name’ with the name of the session variable you are trying to modify. If the variable does not exist, you will need to use a different variable or create it.

2. Use SET SESSION

Instead of using the SET GLOBAL command, use the SET SESSION command to modify session variables. The SET SESSION command only affects the current session and does not require global modification permissions. For example:

SET SESSION variable_name = value;

Replace ‘variable_name’ with the name of the session variable you want to modify and ‘value’ with the desired value.

3. Modify Global Variables

If you need to modify a global variable, ensure that the variable is allowed to be modified globally. Some variables can only be modified at the session level. Refer to the MySQL documentation or consult with a database administrator to determine if the variable can be modified globally.

Summary

MySQL Error 1228 – SQLSTATE: HY000 (ER_LOCAL_VARIABLE) occurs when trying to use a session variable with the SET GLOBAL command. To fix this error:

  • Check that the session variable exists.
  • Use the SET SESSION command instead of SET GLOBAL to modify session variables.
  • Ensure that the variable you want to modify is allowed to be modified globally.

If you are experiencing MySQL Error 1228 or need assistance with VPS hosting, consider Server.HK. Our reliable and high-performance VPS solutions are designed to meet your hosting needs.

Recent Posts

  • NVMe SSD vs SATA SSD for VPS Hosting: Does Storage Type Really Matter?
  • Hong Kong VPS Docker Setup: Run Containers with Full Root Access
  • How to Set Up a Game Server on Hong Kong VPS: Low-Latency Gaming for Asia
  • How to Deploy a Node.js Application on Hong Kong VPS: Complete Guide
  • How to Set Up a WordPress Site on a Hong Kong VPS with aaPanel (Step-by-Step 2026)

Recent Comments

  1. hello world on Top 5 Use Cases for a Hong Kong Dedicated Server in 2026

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot