.OPT

Файл OPT

MySQL Database Options File (db.opt)
Задать вопрос
БЫСТРЫЙ ОТВЕТ

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.

Разработчик: Oracle Corporation (MySQL; originally MySQL AB) Категория: Файлы баз данных MIME: text/plain
ОТКРЫВАЕТСЯ НА Windows macOS Linux
Связанные: .DB · .DBF · .ACCDB · .SQL

На этой странице

Проиндексировано расширений: 19k+
Последняя проверка: Jul 19, 2026

Не знаете, что это за файл?

Перетащите любой файл в наш идентификатор - мы прочитаем первые байты, чтобы определить формат.

Идентифицировать файл

Что такое формат файла OPT?

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.

Безопасность и защита

РИСК: 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.

Детали формата

в двух словах
ПОЛНОЕ НАЗВАНИЕMySQL Database Options File (db.opt)также известен как MySQL db.opt file, MySQL database default options file
РАЗРАБОТЧИКOracle Corporation (MySQL; originally MySQL AB)с Early MySQL (db.opt has existed for many MySQL versions in MyISAM/legacy data directories)
MIME-ТИПtext/plain
ТИПPlain-text configuration file - per-database default character set and collation, named db.opt inside each database directory
СВЯЗАННЫЕ.db.dbf.accdb.sql
Это расширение также используется в…
  • 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.

Программы, открывающие файлы OPT

Windows2 apps
Any text editor (Notepad++ / VS Code) Открытый код 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 Открытый код 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) Бесплатно Open db.opt to read the charset/collation; manage the actual defaults through MySQL, not the file.
Linux2 apps
Any text editor / cat Открытый код 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) Открытый код 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).

Технические подробности

глубокая спецификация
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
ВыпущенEarly MySQL (db.opt has existed for many MySQL versions in MyISAM/legacy data directories)
Последняя версияUsed up to MySQL 5.7; REMOVED in MySQL 8.0 (2018) when metadata moved into the transactional data dictionary
Спецификацияdev.mysql.com

Конвертации OPT

Вопросы и ответы сообщества

спрошено пользователями
Задать быстрый вопрос
Получите помощь от людей, работающих с файлами OPT. Будьте конкретны - укажите вашу систему и версию ПО.
Аккаунт не нужен · ответы обычно в течение дня

Вопросов пока нет - станьте первым, кто спросит о файлах OPT.

Часто задаваемые вопросы

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.

Ссылки

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

Узнать больше

по всей базе данных

Популярные расширения на этой неделе

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.DATProgram Data File (generic)
4.PARTPartial Download File
5.RPMSGRestricted Permission Message
6.EXEWindows Executable (Portable Executable)
7.BINCD/DVD Disc Image (BIN/CUE)
8.DLLDynamic Link Library
9.JPGJPEG Image
10.M4AMPEG-4 Audio File

Похожие расширения

.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

Бесплатные инструменты для файлов

Идентификатор файлов и конвертер изображений в браузере - все работает на вашем устройстве.

Открыть инструменты

Обзор расширений файлов A-Z