> For the complete documentation index, see [llms.txt](https://docs.rivehost.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rivehost.net/rootserver/installationshilfe/mysql-datenbank-installieren.md).

# MySQL-Datenbank installieren

Für die SSH-Verbindungen mit Servern, empfehlen wir, die Verwendung des Programmes "[PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)".<br>

Um sich über SSH mit deinem Root- oder vServer zu verbinden, öffne PuTTY und gebe im Textfeld "**Host Name (or IP address)**" die IP-Adresse deines Servers ein. Klicke anschließend auf "Open", um fortzufahren.

Jetzt trägst du bei "login as" **`root`** ein und bei "password" dein **Server Passwort**.

***

1. Aktualisiere dein System und installiere einige Programme:

```
apt update
```

```
apt upgrade -y
```

#### Schritt 2: Vorbereitung und Installation von PHP

1. **Paketquellen aktualisieren und erforderliche Pakete installieren:**

   ```arduino
   apt install ca-certificates apt-transport-https lsb-release gnupg curl nano unzip -y
   ```
2. **PHP 8 Paketquelle hinzufügen:**
   * **Für Debian:**

     ```ruby
     curl -fsSL https://packages.sury.org/php/apt.gpg -o /usr/share/keyrings/php-archive-keyring.gpg
     echo "deb [signed-by=/usr/share/keyrings/php-archive-keyring.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
     ```
   * **Für Ubuntu:**

     ```bash
     apt install software-properties-common -y
     add-apt-repository ppa:ondrej/php
     ```
3. **Paketlisten aktualisieren:**

   ```sql
   apt update
   ```
4. **Apache2-Webserver und PHP installieren:**

   ```lua
   apt install apache2 -y
   apt install php8.2 php8.2-cli php8.2-common php8.2-curl php8.2-gd php8.2-intl php8.2-mbstring php8.2-mysql php8.2-opcache php8.2-readline php8.2-xml php8.2-xsl php8.2-zip php8.2-bz2 libapache2-mod-php8.2 -y
   ```

#### Schritt 3: MariaDB (MySQL) Installation und Konfiguration

1. **MariaDB-Server und -Client installieren:**

   ```
   apt install mariadb-server mariadb-client -y
   ```
2. **MariaDB konfigurieren:**
   * **Bis einschließlich Debian 10 oder für Ubuntu:**

     ```
     mysql_secure_installation
     ```

     * Bei der ersten Passwortabfrage: Enter drücken.
     * Alle weiteren Schritte mit Enter bestätigen.
   * **Ab Debian 11:**

     ```
     mysql_secure_installation
     ```

     * Bei der ersten Passwortabfrage: Enter drücken.
     * Bei der Unix-Socket-Authentifizierung: "n" eingeben und Enter drücken.
     * Alle weiteren Schritte mit Enter bestätigen.

#### Schritt 4: phpMyAdmin installieren und konfigurieren

1. **phpMyAdmin installieren:**

   ```
   apt install phpmyadmin
   ```
2. **phpMyAdmin mit Apache verknüpfen:**

   ```bash
   sudo ln -s /usr/share/phpmyadmin /var/www/html
   ```

#### Schritt 5: MariaDB-Datenbank und Benutzer einrichten

1. **Mit MariaDB als Root-Benutzer verbinden:**

   ```css
   mysql -u root -p
   ```
2. **Admin-Benutzer und Datenbank erstellen:**

   ```sql
   CREATE USER 'benutzer'@'localhost' IDENTIFIED BY 'passwort';
   CREATE DATABASE meineTestDB;
   GRANT ALL PRIVILEGES ON * . * TO 'benutzer'@'localhost';
   FLUSH PRIVILEGES;
   ```

#### Schritt 5: Zugriff auf phpMyAdmin

* Jetzt können Sie phpMyAdmin über Ihren Webbrowser aufrufen: `http://<Ihre-IP>/phpmyadmin`
* Loggen Sie sich mit dem neu erstellten Benutzernamen (`benutzer`) und Passwort ein.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rivehost.net/rootserver/installationshilfe/mysql-datenbank-installieren.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
