Home  »  GuidesHow ToTechnologyTools   »   How to Fix “ERROR: Loading Local Data is Disabled” in MySQL

How to Fix “ERROR: Loading Local Data is Disabled” in MySQL

MySQL, a popular relational database management system, often enforces security measures to prevent certain potentially risky operations. One such restriction is the “ERROR: Loading local data is disabled” message, which you might encounter when trying to load data from a local file into your MySQL database. In this blog post, we’ll explore why this error occurs and, more importantly, how to fix it.

Understanding the Error

The “ERROR: Loading local data is disabled” error occurs as a security measure to prevent unauthorized users from accessing and loading potentially harmful files into the database. This is to protect the system from potential security risks.

Fixing the Error

To resolve this issue and enable local data loading in MySQL, you have several options. The choice you make depends on the level of security you’re comfortable with and the specific requirements of your MySQL setup.

1. Editing MySQL Configuration Files

The most common and straightforward way to enable local data loading in MySQL is to modify the MySQL configuration file. Here’s how to do it:

  1. Open your MySQL configuration file, usually named my.cnf or my.ini, depending on your system.
  2. Locate the [mysqld] section in the configuration file. If it doesn’t exist, you can add it.
  3. Add the following line to enable local data loading: local-infile=1
  4. Save the configuration file and restart the MySQL server: $ service mysql restart

This change tells MySQL to allow the LOAD DATA LOCAL INFILE command.

2. Using the MySQL Command Line

If you don’t want to edit the MySQL configuration file, you can allow local data loading on a per-session basis using the MySQL command line:

  1. Open your MySQL client with superuser privileges: mysql -u root -p
  2. Enter your MySQL password when prompted.
  3. To enable local data loading for the current session, run the following command: SET GLOBAL local_infile = 'ON'; This change is temporary and only affects the current session. When you close the MySQL client, the setting will revert to its default value.

3. Adding the Option to MySQL Client Commands

If you prefer not to modify the MySQL configuration file or rely on session-specific changes, you can also enable local data loading when executing MySQL client commands:

  1. When running a MySQL client command, such as mysql or mysqldump, add the --local-infile=1 option: mysql -u username -p --local-infile=1 Replace username with your MySQL username. When you run commands with this option, it allows local data loading for that specific operation.


The “ERROR: Loading local data is disabled” error in MySQL is a security measure designed to protect your database from potential security risks. However, with the right approach, you can safely enable local data loading based on your specific needs. You can achieve this by editing the MySQL configuration file, enabling it for a specific session, or including the --local-infile=1 option when executing MySQL client commands. Always consider the security implications when enabling local data loading, and apply the method that aligns with your security and operational requirements.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.

Available under:
Guides, How To, Technology, Tools