.OPT

OPT File

MySQL Database Options File (db.opt)
Ask a question
QUICK ANSWER

In MySQL, an OPT file is the internal db.opt file that stores a database's default character set and collation. You can open it in any text editor to read it, but you should not edit it by hand. MySQL 8.0 (2018) removed this file entirely, so its absence on newer servers is normal.

Developer: Oracle Corporation (MySQL; originally MySQL AB) Category: Database Files MIME: text/plain
OPENS ON Windows macOS Linux
Related: .DB · .DBF · .ACCDB · .SQL

On this page

19k+ extensions indexed
Last reviewed Jul 19, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the OPT file format?

Files with the .opt extension are used to store database character-set properties. Each db.opt file holds two key settings that define the database's default character encoding and collation - specifically a default-character-set= line and a default-collation= line. MySQL database management software saves this information in db.opt files, one per database, located inside that database's subdirectory within the MySQL data directory.

Other MySQL database configuration files

The MySQL data directory can also contain other database-related files, including:

  • .frm - a file containing the database table schema;
  • .myd - a file that stores MyISAM table data;
  • .myi - a file that contains information related to MyISAM table indices;
  • .ibd - a file that stores data and indices of InnoDB tables.

The db.opt file was mandatory in MySQL 5.7 and earlier, created automatically whenever a database was created or its defaults changed. MySQL 8.0 (released 2018) removed db.opt entirely - the database's default character-set and collation are now stored in the transactional data dictionary instead. Editing a db.opt file directly is not recommended; the correct way to set these defaults is through CREATE DATABASE or ALTER DATABASE statements.

Security & safety

RISK: LOW

db.opt is a tiny, passive text file with no executable content, so it poses no direct security risk. The practical cautions are operational: don't hand-edit or delete db.opt on a live MySQL server - change a database's character set/collation with ALTER DATABASE so the server stays consistent; and when copying a pre-8.0 MyISAM database by its raw files, move db.opt together with the database directory so its defaults aren't lost. On MySQL 8.0+ there is no db.opt at all, so its absence in a newer data directory is normal, not a problem.

Format details

in a nutshell
FULL NAMEMySQL Database Options File (db.opt)aka MySQL db.opt file, MySQL database default options file
DEVELOPEROracle Corporation (MySQL; originally MySQL AB)since Early MySQL (db.opt has existed for many MySQL versions in MyISAM/legacy data directories)
MIME TYPEtext/plain
TYPEPlain-text configuration file - per-database default character set and collation, named db.opt inside each database directory
This extension is also used by…
  • Generic 'options/settings' file (.opt) - Many unrelated programs use .opt for their own options/configuration; outside MySQL the extension just means an application's settings file.
  • Origin (OriginLab) options / DVD .OPT / template files - Some tools (e.g. OriginLab, certain DVD authoring) use .opt for their own data; opened only by the originating software, unrelated to MySQL.

Programs that open OPT files

Windows2 apps
Any text editor (Notepad++ / VS Code) Open-source Open db.opt to READ the two charset/collation lines. Do not hand-edit it; change defaults via ALTER DATABASE in MySQL instead.
MySQL server / MySQL Workbench Open-source The proper 'opener' is the MySQL server itself: run 'ALTER DATABASE db CHARACTER SET ...' (or read SCHEMATA in information_schema) - the server manages db.opt for you.
macOS1 app
Any text editor (VS Code, TextEdit) Free Open db.opt to read the charset/collation; manage the actual defaults through MySQL, not the file.
Linux2 apps
Any text editor / cat Open-source View db.opt with a text editor or 'cat db.opt'. It's plain text; change defaults with ALTER DATABASE rather than editing the file.
MySQL server (mysql client) Open-source Use the MySQL client/Workbench to read and change a database's character set/collation - the server keeps db.opt in sync (5.7 and earlier).

Technical details

deep spec
Fixed filenameAlways named db.opt; the .opt extension does not appear independently - the file is identified by its fixed name and directory location, not its extension alone
File formatPlain-text key=value configuration file; no binary structure or header
EncodingASCII / UTF-8, no byte-order mark
Typical file sizeUnder 100 bytes - usually exactly two lines of text
Settings storedExactly two directives: default-character-set=<charset> and default-collation=<collation>
File locationOne db.opt per database, inside that database's subdirectory under the MySQL data directory (e.g. /var/lib/mysql/<dbname>/db.opt on Linux)
Created byMySQL server automatically on CREATE DATABASE; also updated by ALTER DATABASE … CHARACTER SET … COLLATE …
Settings scopePer-database defaults, inherited by new tables and columns unless overridden at the table or column level
MySQL version supportPresent in MySQL 3.x through 5.7; removed entirely in MySQL 8.0 (2018)
Removal reasonMySQL 8.0 replaced file-based metadata with a transactional data dictionary stored in InnoDB, eliminating db.opt and .frm files
MIME typetext/plain
Operating systemsLinux, Windows, macOS - any platform running MySQL Server 5.7 or earlier
Direct editingViewable with any plain-text editor; hand-editing is unsupported and may cause charset/collation inconsistencies between the file and the server's internal state
Superseded byMySQL data dictionary table mysql.schemata (InnoDB-based), which stores default_character_set_name and default_collation_name per schema
ReleasedEarly MySQL (db.opt has existed for many MySQL versions in MyISAM/legacy data directories)
Latest versionUsed up to MySQL 5.7; REMOVED in MySQL 8.0 (2018) when metadata moved into the transactional data dictionary
Specificationdev.mysql.com

OPT conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with OPT files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about OPT files.

Frequently asked questions

What is an OPT (db.opt) file in MySQL?
It's a small text file MySQL keeps inside each database's directory (in 5.7 and earlier) storing that database's default character set and collation. It's managed automatically by CREATE/ALTER DATABASE.
Can I open and read a db.opt file?
Yes - it's plain text. Open it in any editor (Notepad++, VS Code) to see lines like 'default-character-set=utf8mb4'. But don't hand-edit it; change defaults via ALTER DATABASE.
Should I edit db.opt to change my database's character set?
No. Use 'ALTER DATABASE name CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;'. Editing the file directly can desync the server's metadata.
Why does my MySQL 8.0 data directory have no db.opt file?
MySQL 8.0 (2018) removed file-based metadata: db.opt and .frm files were eliminated and their information moved into the transactional data dictionary. Their absence is expected on 8.0+.
Do I need to copy db.opt when moving a MySQL database?
For pre-8.0 MyISAM databases copied by raw files, yes - include db.opt with the database folder so the default charset/collation is preserved. The cleaner method is mysqldump, which records these in the CREATE DATABASE statement.
Is .opt always a MySQL file?
No. Within MySQL, .opt means db.opt. Generally .opt is just a common extension for 'options/settings' files used by many unrelated programs (e.g. OriginLab, various apps) that open only in their own software.

References

1MySQL 8.0 Reference - Removal of File-based Metadata Storagedev.mysql.com
2MySQL Reference - ALTER DATABASE statementdev.mysql.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.MDMarkdown Document
4.BINCD/DVD Disc Image (BIN/CUE)
5.NOMEDIAAndroid No-Media Marker File
6.PARTPartial Download File
7.RPMSGRestricted Permission Message
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.DBSQLite Database File

Related extensions

.DBSQLite Database File
.DBFDatabase File (dBASE / xBase table)
.ACCDBMicrosoft Access Database (2007+)
.SQLSQL Script (Structured Query Language source / database dump)
.MDBMicrosoft Access Database (97-2003, Jet engine)
.FDBFirebird Database

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z