Rechercher dans le manuel MySQL

2.10.1 Initializing the Data Directory

After installing MySQL, the data directory, including the tables in the mysql system database, must be initialized. For some MySQL installation methods, data directory initialization can be done automatically, as described in Section 2.10, “Postinstallation Setup and Testing”. For other installation methods, including installation from generic binary and source distributions, you must initialize the data directory yourself.

This section describes how to initialize the data directory on Unix and Unix-like systems. (For Windows, see Section 2.3.7, “Windows Postinstallation Procedures”.) For some suggested commands that you can use to test whether the server is accessible and working properly, see Section 2.10.3, “Testing the Server”.

In the examples shown here, the server is going to run under the user ID of the mysql login account. This assumes that such an account exists. Either create the account if it does not exist, or substitute the name of a different existing login account that you plan to use for running the server. For information about creating the account, see Creating a mysql System User and Group, in Section 2.2, “Installing MySQL on Unix/Linux Using Generic Binaries”.

  1. Change location into the top-level directory of your MySQL installation directory, which is typically /usr/local/mysql:

    shell> cd /usr/local/mysql

    You will find several files and subdirectories inside the folder, including the bin subdirectory, which contains the server as well as the client and utility programs.

  2. Create a directory whose location can be provided to the secure_file_priv system variable, which limits import/export operations to that specific directory:

    shell> mkdir mysql-files

    Grant ownership of the directory to the mysql user and group ownership to the mysql group, and set the right permissions for the directory:

    shell> chown mysql:mysql mysql-files
    shell> chmod 750 mysql-files
  3. Initialize the data directory, including the mysql database containing the initial MySQL grant tables that determine how users are permitted to connect to the server.

    Typically, data directory initialization need be done only after you first installed MySQL. If you are upgrading an existing installation, you should run mysql_upgrade instead (see Section 4.4.5, “mysql_upgrade — Check and Upgrade MySQL Tables”). However, the command that initializes the data directory does not overwrite any existing privilege tables, so it should be safe to run in any circumstances. Use the server to initialize the data directory; for example:

    shell> bin/mysqld --initialize --user=mysql

    See Section 2.10.1.1, “Initializing the Data Directory Manually Using mysqld” for some important information on the command, especially on the command options you might use.

    Note

    Initialization of the data directory might fail because some required software libraries are missing from your system. For example:

    shell> bin/mysqld --initialize --user=mysql
    bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot
    open shared object file: No such file or directory

    When this happens, you have to install the missing libraries manually or with your system's package manager before retrying the data directory initialization.

  4. If you want the server to be able to deploy with automatic support for secure connections, use the mysql_ssl_rsa_setup utility to create default SSL and RSA files:

    shell> bin/mysql_ssl_rsa_setup

    For more information, see Section 4.4.3, “mysql_ssl_rsa_setup — Create SSL/RSA Files”.

  5. If the plugin directory (the directory named by the plugin_dir system variable) is writable by the server, it may be possible for a user to write executable code to a file in the directory using SELECT ... INTO DUMPFILE. This can be prevented by making the plugin directory read only to the server or by setting the secure_file_priv system variable at server startup to a directory where SELECT writes can be performed safely. (For example, set it to the mysql-files directory created earlier.)

  6. To specify options that the MySQL server should use at startup, put them in a /etc/my.cnf or /etc/mysql/my.cnf file. You can use such a file to set, for example, the secure_file_priv system variable. See Section 5.1.2, “Server Configuration Defaults”. If you do not do this, the server starts with its default settings.

  7. If you want MySQL to start automatically when you boot your machine, see Section 2.10.5, “Starting and Stopping MySQL Automatically”.

Data directory initialization creates time zone tables in the mysql database but does not populate them. To do so, use the instructions in Section 5.1.13, “MySQL Server Time Zone Support”.


Rechercher dans le manuel MySQL

Traduction non disponible

Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-data-directory-initialization.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :en Manuel MySQL : https://dev.mysql.com/

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

Table des matières Haut