Rechercher dans le manuel MySQL
2.10.4 Securing the Initial MySQL Account
The MySQL installation process involves initializing the data
directory, including the grant tables in the
mysql
system schema that define MySQL accounts.
For details, see Section 2.10.1, “Initializing the Data Directory”.
This section describes how to assign a password to the initial
root
account created during the MySQL
installation procedure, if you have not already done so.
Alternative means for performing the process described in this section:
On Windows, you can perform the process during installation with MySQL Installer (see Section 2.3.3, “MySQL Installer for Windows”).
On all platforms, the MySQL distribution includes mysql_secure_installation, a command-line utility that automates much of the process of securing a MySQL installation.
On all platforms, MySQL Workbench is available and offers the ability to manage user accounts (see Chapter 31, MySQL Workbench ).
A password may already be assigned to the initial account under these circumstances:
On Windows, installations performed using MySQL Installer give you the option of assigning a password.
Installation using the macOS installer generates an initial random password, which the installer displays to the user in a dialog box.
Installation using RPM packages generates an initial random password, which is written to the server error log.
Installations using Debian packages give you the option of assigning a password.
For data directory initialization performed manually using mysqld --initialize, mysqld generates an initial random password, marks it expired, and writes it to the server error log. See Section 2.10.1, “Initializing the Data Directory”.
The mysql.user
grant table defines the initial
MySQL user account and its access privileges. Installation of
MySQL creates only a 'root'@'localhost'
superuser account that has all privileges and can do anything. If
the root
account has an empty password, your
MySQL installation is unprotected: Anyone can connect to the MySQL
server as root
without a
password and be granted all privileges.
The 'root'@'localhost'
account also has a row
in the mysql.proxies_priv
table that enables
granting the PROXY
privilege for
''@''
, that is, for all users and all hosts.
This enables root
to set up proxy users, as
well as to delegate to other accounts the authority to set up
proxy users. See Section 6.2.18, “Proxy Users”.
To assign a password for the initial MySQL root
account, use the following procedure. Replace
root-password
in the examples with the
password that you want to use.
Start the server if it is not running. For instructions, see Section 2.10.2, “Starting the Server”.
The initial root
account may or may not have a
password. Choose whichever of the following procedures applies:
If the
root
account exists with an initial random password that has been expired, connect to the server asroot
using that password, then choose a new password. This is the case if the data directory was initialized using mysqld --initialize, either manually or using an installer that does not give you the option of specifying a password during the install operation. Because the password exists, you must use it to connect to the server. But because the password is expired, you cannot use the account for any purpose other than to choose a new password, until you do choose one.If you do not know the initial random password, look in the server error log.
Connect to the server as
root
using the password:shell> mysql -u root -p Enter password: (enter the random root password here)
Choose a new password to replace the random password:
If the
root
account exists but has no password, connect to the server asroot
using no password, then assign a password. This is the case if you initialized the data directory using mysqld --initialize-insecure.
After assigning the root
account a password,
you must supply that password whenever you connect to the server
using the account. For example, to connect to the server using the
mysql client, use this command:
shell> mysql -u root -p
Enter password: (enter root password here)
To shut down the server with mysqladmin, use this command:
For additional information about setting passwords, see
Section 6.2.14, “Assigning Account Passwords”. If you forget your
root
password after setting it, see
Section B.4.3.2, “How to Reset the Root Password”.
To set up additional accounts, see Section 6.2.8, “Adding Accounts, Assigning Privileges, and Dropping Accounts”.
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-default-privileges.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.