Files
J1B4-Fitbot/docs/documentation/raspberryPi/phpMyAdmin/phpMyAdminSetup.md

101 lines
4.7 KiB
Markdown

# phpMyAdmin setup on Raspberry Pi
phpMyAdmin is a free and open-source tool written in PHP that allows you to manage MySQL and MariaDB databases through a web interface. It provides an easy-to-use graphical interface for performing database operations such as creating, editing, and deleting databases, tables, and records.
In this guide, we will show you how to set up phpMyAdmin on your Raspberry Pi. This will allow you to manage your MySQL and MariaDB databases through a web browser.
## Prerequisites
Before you begin, you will need the following:
- A Raspberry Pi with Raspbian installed
- Access to the terminal on your Raspberry Pi
- MySQL or MariaDB installed on your Raspberry Pi
If you have not already installed MySQL or MariaDB, you can follow our guides on [how to install MySQL on your Raspberry Pi](../mysql/mysqlSetup.md) or [how to install MariaDB on your Raspberry Pi](../mariaDB/mariaSetup.md).
## Installation
### Step 1: Install phpMyAdmin
The first step is to install phpMyAdmin on your Raspberry Pi. You can do this by running the following command:
```bash
sudo apt install phpmyadmin
```
During the installation process, you will be prompted to select the web server that you are using. If you are using Apache, select `apache2` by pressing the `Space` key, then press `Tab` to select `OK` and press `Enter` to continue.
You will also be prompted to configure the database for phpMyAdmin. Select `Yes` and enter the root password for your MySQL or MariaDB server when prompted.
### Step 2: Configure phpMyAdmin
After installing phpMyAdmin, you will need to configure it to work with your web server. You can do this by running the following command:
```bash
sudo dpkg-reconfigure phpmyadmin
```
During the configuration process, you will be prompted to select the web server that you are using. If you are using Apache, select `apache2` by pressing the `Space` key, then press `Tab` to select `OK` and press `Enter` to continue.
You will also be prompted to configure the database for phpMyAdmin. Select `Yes` and enter the root password for your MySQL or MariaDB server when prompted.
### Step 3: Access phpMyAdmin
Once you have installed and configured phpMyAdmin, you can access it through a web browser. Open a web browser on your computer and enter the IP address of your Raspberry Pi followed by `/phpmyadmin` in the address bar.
For example, if the IP address of your Raspberry Pi is `145.92.8.132/phpmyadmin`, you would enter `http://145.92.8.132/phpmyadmin` in the address bar.
You will be prompted to enter the username and password for your MySQL or MariaDB server. Enter `root` as the username and the root password that you set during the installation process.
You should now see the phpMyAdmin login page, where you can log in and start managing your databases. If not, you may need to restart the Apache web server by running the following command:
```bash
sudo systemctl restart apache2
```
Check phpMyAdmin Configuration: Ensure that phpMyAdmin is correctly configured in Apache2. There should be a phpMyAdmin configuration file in the /etc/apache2/conf-enabled/ directory named phpmyadmin.conf. If it's not there, you can create a symbolic link to it with:
```bash
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-enabled/phpmyadmin.conf
```
### Step 4: Log in to phpMyAdmin
Once you have restarted the Apache web server, you can log in to phpMyAdmin using the username `root` and the root password that you set during the installation process.
You should now see the phpMyAdmin dashboard, where you can manage your MySQL or MariaDB databases through a web interface.
If not you may need to change the port number in the phpMyAdmin configuration file. You can do this by editing the `config.inc.php` file located in the `/etc/phpmyadmin` directory:
```bash
sudo nano /etc/phpmyadmin/config.inc.php
```
Find the line that starts with `$cfg['Servers'][$i]['host']` and add the port number after the host name. For example, if your MySQL or MariaDB server is running on port `3306`, the line should look like this:
```php
$cfg['Servers'][$i]['host'] = 'localhost:3306';
```
Save the file and restart the Apache web server by running the following command:
```bash
sudo systemctl restart apache2
```
You should now be able to log in to phpMyAdmin using the username `root` and the root password that you set during the installation process.
## Conclusion
You have successfully set up phpMyAdmin on your Raspberry Pi. You can now use phpMyAdmin to manage your MySQL or MariaDB databases through a web interface. If you have any questions or run into any issues, feel free to refer to the [phpMyAdmin documentation](https://docs.phpmyadmin.net/en/latest/) for more information.