|
| 1 | +--- |
| 2 | +title: Configure Bulk Import Operations for SQL Server on Linux |
| 3 | +description: Learn how to configure and use the bulkadmin server role or the ADMINISTER BULK OPERATIONS permission for bulk data import in SQL Server on Linux. |
| 4 | +author: VanMSFT |
| 5 | +ms.author: vanto |
| 6 | +ms.reviewer: matripathy, randolphwest |
| 7 | +ms.date: 03/11/2026 |
| 8 | +ms.service: sql |
| 9 | +ms.subservice: linux |
| 10 | +ms.topic: how-to |
| 11 | +ms.custom: |
| 12 | + - linux-related-content |
| 13 | +ai-usage: ai-assisted |
| 14 | +# customer intent: As a database administrator, I want to configure bulk import operations on SQL Server on Linux so that non-sysadmin users can perform BULK INSERT and OPENROWSET(BULK...) operations securely. |
| 15 | +monikerRange: "=sql-server-ver17 || =sql-server-linux-ver17" |
| 16 | +--- |
| 17 | + |
| 18 | +# Configure bulk import operations for SQL Server on Linux (preview) |
| 19 | + |
| 20 | +[!INCLUDE [sqlserver2025-linux](../includes/applies-to-version/sqlserver2025-linux.md)] |
| 21 | + |
| 22 | +> [!IMPORTANT] |
| 23 | +> This feature is currently in preview. |
| 24 | +
|
| 25 | +Starting with [!INCLUDE [sssql25-md](../includes/sssql25-md.md)] Cumulative Update (CU) 3, you can use the **bulkadmin** server role or the `ADMINISTER BULK OPERATIONS` permission to perform bulk data import operations on [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] running on Linux. Previously, only members of the **sysadmin** server role could run [BULK INSERT](../t-sql/statements/bulk-insert-transact-sql.md) or [OPENROWSET(BULK...)](../relational-databases/import-export/import-bulk-data-by-using-bulk-insert-or-openrowset-bulk-sql-server.md) on Linux. |
| 26 | + |
| 27 | +[!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] on Linux enforces additional file system and path validation checks for bulk operations, beyond what's required on Windows. An administrator must: |
| 28 | + |
| 29 | +- Grant appropriate [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] permissions to the user |
| 30 | +- Grant Linux file system permissions on the data files |
| 31 | +- Explicitly approve directory paths using `mssql-conf` |
| 32 | + |
| 33 | +## Prerequisites |
| 34 | + |
| 35 | +- [!INCLUDE [sssql25-md](../includes/sssql25-md.md)] CU 3 or later version on Linux |
| 36 | +- Administrative access to the Linux host |
| 37 | +- Administrative access to the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] instance |
| 38 | + |
| 39 | +## Configure the Linux file system |
| 40 | + |
| 41 | +Before you can run bulk import operations, the `mssql` service account must have read access to the data files on the Linux file system. |
| 42 | + |
| 43 | +1. Create a directory for your bulk data files: |
| 44 | + |
| 45 | + ```bash |
| 46 | + mkdir -p /tmp/bulkload/sales/ |
| 47 | + ``` |
| 48 | + |
| 49 | +1. Create a sample data file: |
| 50 | + |
| 51 | + ```bash |
| 52 | + cat > /tmp/bulkload/sales/loadsalesdata.csv << EOF |
| 53 | + Id,CustomerName,OrderDate,Amount |
| 54 | + 1,John Doe,2026-02-01,500.75 |
| 55 | + 2,Jane Smith,2026-02-05,1500.20 |
| 56 | + 3,Mark Lee,2026-02-10,320.50 |
| 57 | + 4,Alice Johnson,2026-02-15,785.00 |
| 58 | + 5,Bob Brown,2026-02-20,930.40 |
| 59 | + EOF |
| 60 | + ``` |
| 61 | +
|
| 62 | +1. Grant read permission to the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] process account (`mssql`) on the data file: |
| 63 | +
|
| 64 | + ```bash |
| 65 | + setfacl -m u:mssql:r /tmp/bulkload/sales/loadsalesdata.csv |
| 66 | + ``` |
| 67 | +
|
| 68 | +## Configure allowed paths with mssql-conf |
| 69 | +
|
| 70 | +An administrator must approve the directories from which bulk operations can read, using the `bulkadmin.allowedpathslist` setting in `mssql-conf`. This change takes effect immediately and doesn't require a [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] service restart. |
| 71 | +
|
| 72 | +```bash |
| 73 | +sudo /opt/mssql/bin/mssql-conf set bulkadmin.allowedpathslist "/tmp/bulkload/sales" |
| 74 | +``` |
| 75 | +
|
| 76 | +To specify multiple directories, separate each path with a colon (`:`): |
| 77 | +
|
| 78 | +```bash |
| 79 | +sudo /opt/mssql/bin/mssql-conf set bulkadmin.allowedpathslist "/tmp/bulkload/sales:/tmp/bulkload/marketing" |
| 80 | +``` |
| 81 | +
|
| 82 | +Alternatively, you can specify a parent directory to allow all subdirectories under it. |
| 83 | +
|
| 84 | +### Path restrictions |
| 85 | +
|
| 86 | +The following restrictions apply to paths configured for bulk operations: |
| 87 | +
|
| 88 | +- The path must be an absolute path. Relative paths containing `.` or `..` aren't allowed. |
| 89 | +- The root path (`/`) isn't allowed. |
| 90 | +- The path must not exceed 4,096 characters. |
| 91 | +- The path must not contain invalid characters (null, newline, carriage return, or tab). |
| 92 | +- Symbolic links aren't allowed. |
| 93 | +- The path must refer to a directory. |
| 94 | +
|
| 95 | +### Forbidden paths |
| 96 | +
|
| 97 | +The system blocks some critical paths by design. You can't use these locations as source data file paths for bulk operations, even if you add them to the allowed paths list: |
| 98 | +
|
| 99 | +- `/var/opt/mssql` (or the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] installation directory) |
| 100 | +- `/var/opt/azcmagent/certs` |
| 101 | +- `/var/opt/azcmagent/tokens` |
| 102 | +
|
| 103 | +Bulk operations that read source data from these paths fail for security reasons. This restriction doesn't apply to the `ERRORFILE` output path, which uses the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] data directory by default. |
| 104 | +
|
| 105 | +## Set up SQL Server permissions |
| 106 | +
|
| 107 | +After you configure the Linux file system and allowed paths, set up the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] permissions for the user who performs the bulk import. |
| 108 | +
|
| 109 | +1. Connect to the [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] instance and create a sample database and table: |
| 110 | +
|
| 111 | + ```sql |
| 112 | + CREATE DATABASE demodbforbulkinsert; |
| 113 | + GO |
| 114 | +
|
| 115 | + USE demodbforbulkinsert; |
| 116 | + GO |
| 117 | +
|
| 118 | + CREATE TABLE dbo.Sales ( |
| 119 | + Id INT NOT NULL PRIMARY KEY, |
| 120 | + CustomerName NVARCHAR(200) NOT NULL, |
| 121 | + OrderDate DATE NOT NULL, |
| 122 | + Amount DECIMAL(18, 2) NOT NULL |
| 123 | + ); |
| 124 | + GO |
| 125 | + ``` |
| 126 | +
|
| 127 | +1. Create a login for the bulk import user: |
| 128 | +
|
| 129 | + ```sql |
| 130 | + USE master; |
| 131 | + GO |
| 132 | +
|
| 133 | + CREATE LOGIN BulkLoadUser WITH PASSWORD = '<strong_password>'; |
| 134 | + GO |
| 135 | + ``` |
| 136 | +
|
| 137 | +1. Grant the `ADMINISTER BULK OPERATIONS` permission or add the login to the **bulkadmin** server role. Use one of the following options: |
| 138 | +
|
| 139 | + ```sql |
| 140 | + -- Option 1: Add to the bulkadmin server role |
| 141 | + ALTER SERVER ROLE bulkadmin ADD MEMBER BulkLoadUser; |
| 142 | + GO |
| 143 | + ``` |
| 144 | +
|
| 145 | + ```sql |
| 146 | + -- Option 2: Grant the permission directly |
| 147 | + GRANT ADMINISTER BULK OPERATIONS TO BulkLoadUser; |
| 148 | + GO |
| 149 | + ``` |
| 150 | +
|
| 151 | +1. Create a database user and grant the necessary table permissions: |
| 152 | +
|
| 153 | + ```sql |
| 154 | + USE demodbforbulkinsert; |
| 155 | + GO |
| 156 | +
|
| 157 | + CREATE USER BulkLoadUser FOR LOGIN BulkLoadUser; |
| 158 | + GO |
| 159 | +
|
| 160 | + GRANT INSERT, SELECT ON dbo.Sales TO BulkLoadUser; |
| 161 | + GO |
| 162 | + ``` |
| 163 | +
|
| 164 | +## Run a bulk import |
| 165 | +
|
| 166 | +Connect to the database as the `BulkLoadUser` login and run the bulk import: |
| 167 | +
|
| 168 | +```sql |
| 169 | +USE demodbforbulkinsert; |
| 170 | +GO |
| 171 | +
|
| 172 | +BULK INSERT dbo.Sales |
| 173 | +FROM '/tmp/bulkload/sales/loadsalesdata.csv' |
| 174 | +WITH ( |
| 175 | + FIRSTROW = 2, |
| 176 | + FIELDTERMINATOR = ',', |
| 177 | + ERRORFILE = '/var/opt/mssql/data/bulk_errors' |
| 178 | +); |
| 179 | +GO |
| 180 | +
|
| 181 | +-- Verify the imported data |
| 182 | +SELECT * FROM dbo.Sales; |
| 183 | +GO |
| 184 | +``` |
| 185 | +
|
| 186 | +The same permissions, Linux file system configuration, and path approval steps apply to `INSERT ... SELECT * FROM OPENROWSET(BULK...)` statements. For more information, see [Import bulk data by using BULK INSERT or OPENROWSET(BULK...)](../relational-databases/import-export/import-bulk-data-by-using-bulk-insert-or-openrowset-bulk-sql-server.md). |
| 187 | +
|
| 188 | +## Upgrade and downgrade behavior |
| 189 | +
|
| 190 | +Starting with [!INCLUDE [sssql25-md](../includes/sssql25-md.md)] CU 3, [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] on Linux supports bulk operations using the **bulkadmin** role or `ADMINISTER BULK OPERATIONS` permission. |
| 191 | +
|
| 192 | +If you uninstall CU 3 or downgrade to an earlier cumulative update: |
| 193 | +
|
| 194 | +- Previously granted permissions remain assigned but aren't functional. |
| 195 | +- Bulk operations require **sysadmin** permissions, as in versions prior to CU 3. |
| 196 | +
|
| 197 | +## Related content |
| 198 | +
|
| 199 | +- [BULK INSERT (Transact-SQL)](../t-sql/statements/bulk-insert-transact-sql.md) |
| 200 | +- [Import bulk data by using BULK INSERT or OPENROWSET(BULK...)](../relational-databases/import-export/import-bulk-data-by-using-bulk-insert-or-openrowset-bulk-sql-server.md) |
| 201 | +- [Security considerations for SQL Server on Linux](sql-server-linux-security-overview.md) |
| 202 | +- [SQL Server on Linux - Security and permissions guide](sql-server-linux-security-permissions-guide.md) |
| 203 | +- [Configure SQL Server on Linux with the mssql-conf tool](sql-server-linux-configure-mssql-conf.md) |
0 commit comments