Mysqld что это linux

What is mysqld?

What is the mySQL daemon? Why do developers care about it, and what does it do?

9 months ago • 6 min read


The MySQL Server has many different names and has been around for decades. Some people simply call it “MySQL,” some refer to it as “the MySQL daemon,” and others still elect to simply combine the two and call it “mysqld” (short for “MySQL daemon”). Regardless, the fact remains that it is both extremely popular and used in almost every industry we can think of. People working with the server generally use it to support software solutions on the web, but its use cases vary from industry to industry thanks to its high availability, performance including data storage and security.

  • High availability. When supporting educational, hospitality, or financial services, the high availability features of MySQL are paramount. Since the daemon has a plethora of load balancers that can be implemented (ProxySQL, MaxScale, HAProxy, and the like), it plays a crucial role in ensuring the uptime of the infrastructure in high schools, universities, and other educational institutions.
  • Performance. When behind a highly technical organization, the daemon is used in all kinds of scenarios and can push the performance of an application backing a business to the max. That’s the reason MySQL has documentation behind it in the first place–highly technical people can always direct their staff there to learn how, why, and when MySQL behaves the way it does.
  • Simplicity. Finally, there are use cases where the daemon is there just to have some data inside of it. In such a case, people running a service that’s backed by MySQL may not know a lot of things about it, may not care enough to learn, or both–it’s good as long as it works.

The science behind the daemon

The core reason the MySQL daemon exists is to let us “get under the hood” of MySQL and run commands as if we’re inside of the database via the CLI:

Basic output of the CLI

To see everything it can do, we launch it with the —help option:

Launching mysqld with the —help option

And to see all mysqld options in a nice format, invoke mysqld —verbose .

The MySQL Daemon with the —verbose Option

The above command will let us see everything the daemon can do; from usage options to variables–everything’s here.

Everything the Daemon can do

How does the configuration work?

The daemon allows us to see everything our MySQL instance is built on, but to properly understand everything that we have to handle, we must look into the configuration itself. The MySQL configuration file is located in the /var/lib/mysql/ directory on Linux and inside of the MySQL version folder on Windows, and it’s called either my.cnf or my.ini , respectively. The contents of the file are pretty much the same on both operating systems, though there are slightly more comments on the Windows version of the file. An example can be seen below:

The Initial Configuration File for MySQL 5.7.26 on a Windows-based Infrastructure

The file contains every setting that is displayed by the daemon, ranging from settings relevant to the MySQL client itself to SQL modes. All of these options can be also set at runtime by using parameters beginning by “—”: we can make MySQL run in an ANSI mode by specifying mysqld —ansi , we can specify the amount of I/O threads available for use by specifying their number (#) in mysqld —innodb-write-io-threads=# , etc.

The configuration works this way because it contains the parameters (sometimes also called variables) which then interact with the daemon, and consequently alter how the daemon (MySQL) functions as a whole.

Читайте также:  Как подключить принтер через общую сеть

Configuring mysqld for storage and security

A lot of parameters impact how MySQL functions. Some of the more interesting ones alter its functionality as an ecosystem, some allow MySQL to remain stable, and some lesser-known ones have less impact. Of the parameters affecting storage and security, secure_file_priv impacts both and deserves a mention.

secure_file_priv and other mysqld parameters

One of the most popular parameters is the secure_file_priv variable. This parameter controls where MySQL is allowed to ingest data when the LOAD DATA INFILE statement is being used. The default value for MySQL on Windows is the tmp directory: secure_file_priv=”c:/wamp64/tmp”

This variable is important because it puts a restraint on which directories can contain data that is eligible for inclusion in your MySQL database instance. If we load data into MySQL from the wrong directory, we will see a message outlining that we should choose a different folder: ERROR 1290 (HY000): The MySQL server is running with the —secure-file-priv option so it cannot execute this statement

Configure mysqld for big data

Of course, secure_file_priv is not alone. We have a lot of other variables to choose from, including, but not limited to:

  • The log-isam=filename variable, which is useful if we want to log all changes relevant to MyISAM into one file.
  • The innodb-data-home-dir parameter, which makes it possible for us to change the default home directory for files related to the InnoDB storage engine.
  • The innodb-ft-total-cache-size parameter, which gives us the ability to adjust the size of the fulltext index cache to use TEXT type data most efficiently in mysql.

In our big data and MySQL post above, we covered how to configure the buffer pool size, buffer pool instances, and level of ACID compliance so that MySQL can handle the maximum amount of data.

Configure the MySQL daemon for high security

The last example we will cover in this post is encryption. There are hundreds of mysqld parameters spanning hundreds of use cases–if you really want to dive deep, consider taking a look into the list of parameters provided by MySQL.

In the SSL post above we covered how to modify parameters like.

  • require_secure_transport
  • bind_address
  • have_openssl
  • have_ssl

. to support securely connecting to MySQL. With the server configured, you can use the SSL options in a MySQL client to be sure your connection is encrypted!


mysqld , the MySQL daemon, MySQL Server, or simply MySQL works behind-the-scenes on millions of websites across thousands of industries around the world: it is used by worldwide social media giants such as Facebook, by the world’s fastest data breach search engines, and by small startups alike. A proper understanding of what the daemon is, what it does, and why it’s used is absolutely crucial for every developer and database administrator.

Over the past couple of years, MySQL has evolved heavily, adding a lot of new parameters to expand its use cases even further, and it’s now the modern king in the data space for a reason: MySQL has given developers an awesome opportunity to get inside of its “brain,” and mysqld is largely responsible for that adaptability.


Mysqld что это linux

mysqld , also known as MySQL Server, is a single multithreaded program that does most of the work in a MySQL installation. It does not spawn additional processes. MySQL Server manages access to the MySQL data directory that contains databases and tables. The data directory is also the default location for other information such as log files and status files.

Some installation packages contain a debugging version of the server named mysqld-debug . Invoke this version instead of mysqld for debugging support, memory allocation checking, and trace file support (see Section, “Creating Trace Files”).

When MySQL server starts, it listens for network connections from client programs and manages access to databases on behalf of those clients.

The mysqld program has many options that can be specified at startup. For a complete list of options, run this command:

Читайте также:  Linux sed перевод строки

MySQL Server also has a set of system variables that affect its operation as it runs. System variables can be set at server startup, and many of them can be changed at runtime to effect dynamic server reconfiguration. MySQL Server also has a set of status variables that provide information about its operation. You can monitor these status variables to access runtime performance characteristics.

For a full description of MySQL Server command options, system variables, and status variables, see Section 5.1, “The MySQL Server”. For information about installing MySQL and setting up the initial configuration, see Chapter 2, Installing and Upgrading MySQL.




MySQL — свободная СУБД для малых и средних приложений. Входит в состав LAMP и XAMPP.

Версии MySQL в Ubuntu


MySQL есть в репозиториях Ubuntu. Он разбит на несколько пакетов.

Для того чтобы установить MySQL сервер выполните команду:

При установке конфигурационный скрипт запросит пароль для администратора (root) базы данных.

Для того чтобы установить консольный клиент MySQL выполните команду:

Для того чтобы установить модуль для работы с MySQL в PHP выполните команду:


Конфигурация сервера MySQL содержится в файле /etc/mysql/my.cnf.

Доступ к серверу из сети

По умолчанию сервер MySQL принимает соединения только с локальной машины. Для того, чтобы разрешить подключаться к нему с других машин замените строку


По-умолчанию в Ubuntu MySQL устанавливается с кодировкой latin1 . В этом можно убедиться посмотрев вывод запроса:

В связи с этим, даже используя при работе с сервером команду

и используя при создании таблиц

невозможно добиться полной поддержки кодировки utf8:

Кодировка по-умолчанию все равно останется latin1, что неудобно и может привести к ошибкам.

Чтобы сервер сразу загружался с нужной кодировкой, необходимо отредактировать файл /etc/mysql/my.cnf:

В секцию [mysqld] добавьте следующие строки:

Так же желательно установить кодировку для клиента и mysqldump. Для этого в секциях [client] и [mysqldump] необходимо добавить строчку:

Перезагрузите сервер MySQL:

После этого список переменных будет выглядеть так:


Установка root пароля

Восстановление забытого пароля для root’a

Схожая проблема возникает если не задать пароль при установке MySQL, в этом случае mysql использует плагин unix-socket.

Запустите mysqld с параметрами —skip-grant-tables —user=root :

Если команда не сработает, добавьте строку « skip-grant-tables » в секцию « [mysqld] » файла /etc/mysql/mysql.conf.d/mysqld.cnf . Затем выполните sudo service mysql restart . После выполнения операций удалите эту строку.

Подключитесь к MySQL-серверу командой:

Обновите пароль для root’a:

Для MySQL версий mysqldump . Основные ее параметры приведены в таблице:

Параметр Описание Пример
-u Пользователь, от лица которого будет производится дамп баз данных. -uroot

Пароль пользователя. Пароль необязательно указывать, достаточно упомянуть этот параметр для того, чтобы утилита знала что подключение требует пароля. -ppassword
-p -h Хост, на котором расположена база данных. -h127.0.0.1 -A Создать бекап всех баз данных. -A -B Базы данных, которые нужно забэкапить. -B db1 db2 db3 —tables

Таблицы, которые нужно забэкапить. Перекрывает действие ключа -B —tables db1.table1 db1.table2 db2.table3 -d Создать бекап структуры таблиц. Содержимое таблиц скопировано не будет. -d —skip-extended-insert Не использовать многострочные INSERT-записи при создании дампа. —skip-extended-insert -w’where_clause ‘ Создавать дамп только тех строк, которые попадают под условие. -w’Id > 10 AND Id ‘

Отключение и включение автозагрузки сервиса

Начиная с версии Ubuntu 15.04 отключение и включение сервисов возможно одной командой, без редактирования конфигов. В примерах команд ниже слово «SERVICE» следует заменить на «mysql».

Узнать стоит ли сервис в автозагрузке:

Убрать сервис из автозагрузки в Ubuntu-16.04:

Добавить сервис в автозагрузку в Ubuntu-16.04:

MySQL Workbench

MySQL Workbench – инструмент для визуального проектирования баз данных. MySQL Workbench существует в двух вариантах:


Mysqld что это linux

MySQL distributions on Unix and Unix-like system include a script named mysql.server , which starts the MySQL server using mysqld_safe . It can be used on systems such as Linux and Solaris that use System V-style run directories to start and stop system services. It is also used by the macOS Startup Item for MySQL.

mysql.server is the script name as used within the MySQL source tree. The installed name might be different (for example, mysqld or mysql ). In the following discussion, adjust the name mysql.server as appropriate for your system.

For some Linux platforms, MySQL installation from RPM or Debian packages includes systemd support for managing MySQL server startup and shutdown. On these platforms, mysql.server and mysqld_safe are not installed because they are unnecessary. For more information, see Section 2.5.9, “Managing MySQL Server with systemd”.

To start or stop the server manually using the mysql.server script, invoke it from the command line with start or stop arguments:

mysql.server changes location to the MySQL installation directory, then invokes mysqld_safe . To run the server as some specific user, add an appropriate user option to the [mysqld] group of the global /etc/my.cnf option file, as shown later in this section. (It is possible that you must edit mysql.server if you’ve installed a binary distribution of MySQL in a nonstandard location. Modify it to change location into the proper directory before it runs mysqld_safe . If you do this, your modified version of mysql.server may be overwritten if you upgrade MySQL in the future; make a copy of your edited version that you can reinstall.)

mysql.server stop stops the server by sending a signal to it. You can also stop the server manually by executing mysqladmin shutdown .

To start and stop MySQL automatically on your server, you must add start and stop commands to the appropriate places in your /etc/rc* files:

If you use the Linux server RPM package ( MySQL-server- VERSION .rpm ), or a native Linux package installation, the mysql.server script may be installed in the /etc/init.d directory with the name mysqld or mysql . See Section 2.5.4, “Installing MySQL on Linux Using RPM Packages from Oracle”, for more information on the Linux RPM packages.

If you install MySQL from a source distribution or using a binary distribution format that does not install mysql.server automatically, you can install the script manually. It can be found in the support-files directory under the MySQL installation directory or in a MySQL source tree. Copy the script to the /etc/init.d directory with the name mysql and make it executable:

After installing the script, the commands needed to activate it to run at system startup depend on your operating system. On Linux, you can use chkconfig :

On some Linux systems, the following command also seems to be necessary to fully enable the mysql script:

On FreeBSD, startup scripts generally should go in /usr/local/etc/rc.d/ . Install the mysql.server script as /usr/local/etc/rc.d/ to enable automatic startup. The rc(8) manual page states that scripts in this directory are executed only if their base name matches the *.sh shell file name pattern. Any other files or directories present within the directory are silently ignored.

As an alternative to the preceding setup, some operating systems also use /etc/rc.local or /etc/init.d/boot.local to start additional services on startup. To start up MySQL using this method, append a command like the one following to the appropriate startup file:

For other systems, consult your operating system documentation to see how to install startup scripts.

mysql.server reads options from the [mysql.server] and [mysqld] sections of option files. For backward compatibility, it also reads [mysql_server] sections, but to be current you should rename such sections to [mysql.server] .

You can add options for mysql.server in a global /etc/my.cnf file. A typical my.cnf file might look like this:

The mysql.server script supports the options shown in the following table. If specified, they must be placed in an option file, not on the command line. mysql.server supports only start and stop as command-line arguments.

Table 4.7 mysql.server Option-File Options

Option Name Description Type
basedir Path to MySQL installation directory Directory name
datadir Path to MySQL data directory Directory name
pid-file File in which server should write its process ID File name
service-startup-timeout How long to wait for server startup Integer

The path to the MySQL installation directory.

The path to the MySQL data directory.

The path name of the file in which the server should write its process ID. The server creates the file in the data directory unless an absolute path name is given to specify a different directory.


Поделиться с друзьями