GNU/Linux >> LINUX-Kenntnisse >  >> Cent OS

So installieren Sie MySQL 8.0/5.7 unter CentOS 7 / RHEL 7

MySQL ist ein kostenloses Open-Source-Datenbankverwaltungssystem, das häufig in Webanwendungen zum Speichern und Abrufen von Datensätzen und Informationen verwendet wird.

MySQL wurde ursprünglich von MYSQL AB entwickelt, das sich jetzt im Besitz der Oracle Corporation befindet. Es war die primäre Datenbankanwendung für das Linux-Betriebssystem, bis MariaDB, eine Abzweigung von MySQL, ins Bild kam.

In diesem Artikel erfahren Sie, wie Sie MySQL 8.0/5.7 unter CentOS 7 / RHEL 7 installieren.

MySQL-Repository hinzufügen

MySQL wird nicht mehr über Betriebssystem-Repositories verteilt. Sie müssten also ein offizielles MySQL-Repository hinzufügen, um den MySQL-Community-Server zu installieren.

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-4.noarch.rpm

Stellen Sie sicher, dass das MySQL-Repository hinzugefügt und aktiviert wurde, indem Sie den folgenden Befehl verwenden.

yum repolist all | grep mysql | grep enabled

Ausgabe:Kann aussehen wie.

mysql-connectors-community/x86_64   MySQL Connectors Community   enabled:    221
mysql-tools-community/x86_64        MySQL Tools Community        enabled:    135
mysql80-community/x86_64            MySQL 8.0 Community Server   enabled:    301

MySQL Community Server installieren

Oracle bietet derzeit beide stabilen Versionen (v8.0 und v5.7) an. Sie können diejenige auswählen, die Sie auf Ihrem Computer installieren möchten.

Installieren Sie MySQL 8.0

Verwenden Sie den Befehl yum, um MySQL Community Server 8.0 zu installieren.

yum install -y mysql-community-server

Installieren Sie MySQL 5.7

Wenn Sie die ältere Version von MySQL ausprobieren möchten, installieren Sie MySQL 5.7 mit dem folgenden Befehl auf Ihrem Computer.

yum install -y mysql-community-server --disablerepo=mysql80-community --enablerepo=mysql57-community

Nach der Installation von MySQL können Sie den MySQL-Server mit folgendem Befehl starten.

systemctl start mysqld

Aktivieren Sie dann den MySQL-Dienst so, dass er beim Systemstart automatisch gestartet wird.

systemctl enable mysqld

Überprüfen Sie schließlich mit dem folgenden Befehl, ob der MySQL-Server gestartet wurde.

systemctl status mysqld

Anfängliches MySQL-Root-Passwort

In CentOS/RHEL finden Sie das anfängliche MySQL-Root-Passwort in /var/log/mysqld.log . Sie können den folgenden Befehl verwenden, um das Passwort aus der Protokolldatei zu entnehmen.

cat /var/log/mysqld.log | grep -i 'temporary password'

Ausgabe:

2021-11-27T08:27:27.063799Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: PJyCjhTjP1:n

Sicherer MySQL-Server

Jetzt müssen Sie mysql_secure_installation ausführen um Ihre MySQL-Installation zu sichern. Dieser Befehl kümmert sich um das Setzen des Root-Passworts, das Entfernen anonymer Benutzer, das Verbieten der Root-Anmeldung aus der Ferne usw.

mysql_secure_installation

Ausgabe:

Securing the MySQL server deployment.

Enter password for user root:  << Enter the initital MySQL root password

The existing password for the user account root has expired. Please set a new password.

New password:  << Enter new MySQL root password

Re-enter new password:  << Re-enter new MySQL root password
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N  << Type N as we have already set new password

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y  << Type Y to remove anonymous users
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y  << Type Y to disallow root login remotely
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y  << Type Y to remove test database
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y  << Type Y to reload privilege tables
Success.

All done!

Mit MySQL-Server arbeiten

Melden Sie sich mit dem Root-Benutzer und seinem Passwort beim MySQL-Server an.

mysql -u root -p

Ausgabe:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Installieren Sie phpMyAdmin

phpMyAdmin ist ein webbasiertes Open-Source-Verwaltungstool zur Verwaltung von MySQL- und MariaDB-Datenbanken. Folgen Sie dem Link unten, um phpMyAdmin basierend auf Ihrem Betriebssystem zu installieren und zu konfigurieren.

LESEN:Installieren Sie phpMyAdmin auf CentOS 7 / RHEL 7

Schlussfolgerung

Das ist alles. Ich hoffe, Sie haben gelernt, wie man MySQL 8.0/5.7 auf CentOS 7 / RHEL 7 installiert.


Cent OS
  1. Deaktivieren Sie SELinux auf CentOS oder RHEL 5/5.1/5.2/5.3/5.4/5.5/5.6/5.7

  2. So installieren Sie Apache, MySQL, PHP (LAMP) unter CentOS/RHEL 7

  3. So installieren Sie MySQL 8.0 unter CentOS/RHEL 8

  4. Wie installiere ich MySQL unter CentOS 7.x?

  5. So installieren Sie MySQL 5.6 unter CentOS 6.x

So installieren Sie Compass auf RHEL 8 / CentOS 8

So installieren Sie Puppet unter RHEL 8 / CentOS 8

So installieren Sie MySQL unter CentOS 8

So installieren Sie ONLYOFFICE unter Red Hat Linux (RHEL) und CentOS

So installieren Sie Cacti unter CentOS 6 / RHEL 6

So installieren Sie MySQL 8.0 unter CentOS 8 / RHEL 8