PhpMyAdmin: verschil tussen versies

Uit Installatie Rocky 9 Webserver
Naar navigatie springen Naar zoeken springen
Geen bewerkingssamenvatting
Geen bewerkingssamenvatting
 
(5 tussenliggende versies door dezelfde gebruiker niet weergegeven)
Regel 1: Regel 1:
[[Hoofdpagina|Menu]]  [[WireGuard]] [[Mariadb]]


= phpMyAdmin =
= phpMyAdmin =


 
  # cd /var/www/html/
[[Hoofdpagina|WireGuard]]
  <code># cd /var/www/html/
  # curl -LO <nowiki>https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.tar.gz</nowiki>
  # curl -LO <nowiki>https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.tar.gz</nowiki>
  # tar xf phpMyAdmin-5.2.0-all-languages.tar.gz
  # tar xf phpMyAdmin-5.2.0-all-languages.tar.gz
Regel 23: Regel 22:
      Require all granted
      Require all granted
  #    Require all denied
  #    Require all denied
  #    Require ip 10.0.36.0/24
  #    Require ip 10.0.0.0/24 (eigen ip-reeks)
      <FilesMatch "\.(inc|php)$">
      <FilesMatch "\.(inc|php)$">
          <If "-f %{REQUEST_FILENAME}">
          <If "-f %{REQUEST_FILENAME}">
Regel 30: Regel 29:
      </FilesMatch>
      </FilesMatch>
  </Directory>
  </Directory>
  ==================================================</code>
  =================================================
Om gebruik te maken van phpMyAdmin moet je wel een database hebben.
Om gebruik te maken van phpMyAdmin moet je wel een database hebben.


Regel 36: Regel 35:
  <code>sudo dnf install mariadb-server mariadb</code>
  <code>sudo dnf install mariadb-server mariadb</code>
Dependency Tree:
Dependency Tree:
  <Transaction Summary
  Transaction Summary
  ================================================================================
  ================================================================================
  Install  13 Packages
  Install  13 Packages
Regel 42: Regel 41:
  Total download size: 18 M
  Total download size: 18 M
  Installed size: 107 M
  Installed size: 107 M
  Is this ok [y/N]: y</code>
  Is this ok [y/N]: y
Once installed, start and enable MariaDB the service:
Once installed, start and enable MariaDB the service:
  <code>sudo systemctl enable --now mariadb</code>
  <code>sudo systemctl enable --now mariadb</code>
Verify if the service is running:
Verify if the service is running:
  <$ systemctl status mariadb
  $ systemctl status mariadb
  ● mariadb.service - MariaDB 10.5 database server
  ● mariadb.service - MariaDB 10.5 database server
       Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
       Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Regel 61: Regel 60:
         CPU: 268ms
         CPU: 268ms
       CGroup: /system.slice/mariadb.service
       CGroup: /system.slice/mariadb.service
               └─20448 /usr/libexec/mariadbd --basedir=/usr</code>
               └─20448 /usr/libexec/mariadbd --basedir=/usr


== #2. Using MariaDB on Rocky Linux 9|AlmaLinux 9 ==
== #2. Using MariaDB on Rocky Linux 9|AlmaLinux 9 ==
Regel 67: Regel 66:
  <code>sudo mysql_secure_installation</code>
  <code>sudo mysql_secure_installation</code>
Proceed as shown: On MariaDB:
Proceed as shown: On MariaDB:
  <NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
  NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
       SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
       SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
   
   
Regel 101: Regel 100:
  installation should now be secure.
  installation should now be secure.
   
   
  Thanks for using MariaDB!</code>
  Thanks for using MariaDB!
Now login using the created root password:
Now login using the created root password:
  <$ mysql -u root -p
  $ mysql -u root -p
  Enter password:  
  Enter password:  
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Welcome to the MySQL monitor.  Commands end with ; or \g.
Regel 117: Regel 116:
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
   
   
  mysql></code>
  mysql>


  <code>mysql>  SELECT VERSION();</code>
  <code>mysql>  SELECT VERSION();</code>
Regel 124: Regel 123:
=== Create a User and Database: ===
=== Create a User and Database: ===
To create a user and database in MariaDB/MySQL, use the commands below replacing where required:
To create a user and database in MariaDB/MySQL, use the commands below replacing where required:
  <CREATE DATABASE sampledb;
  CREATE DATABASE sampledb;
  CREATE USER 'test_user'@'%' IDENTIFIED BY 'Passw0rd';
  CREATE USER 'test_user'@'%' IDENTIFIED BY 'Passw0rd';
  GRANT ALL ON sampledb.* TO 'test_user'@'%' WITH GRANT OPTION;
  GRANT ALL ON sampledb.* TO 'test_user'@'%' WITH GRANT OPTION;
  FLUSH PRIVILEGES;</code>
  FLUSH PRIVILEGES;
After this, you will have a database named '''sampledb''' and a user '''test_user''' who can be accessed remotely created as swell.
After this, you will have a database named '''sampledb''' and a user '''test_user''' who can be accessed remotely created as swell.


Regel 143: Regel 142:
  5 rows in set (0.00 sec)
  5 rows in set (0.00 sec)
   
   
  mysql></code>  
  mysql>  
View users:
View users:
  <mysql> SELECT User, Host FROM mysql.user;
  <mysql> SELECT User, Host FROM mysql.user;
Regel 157: Regel 156:
  5 rows in set (0.00 sec)
  5 rows in set (0.00 sec)
   
   
  mysql></code>  
  mysql>  
To delete a user, use the command with the below syntax:
To delete a user, use the command with the below syntax:
  <code>DROP USER 'username'@'host';</code>
  <code>DROP USER 'username'@'host';</code>
Regel 163: Regel 162:
=== Create Tables ===
=== Create Tables ===
We can then create and insert data into a table. For example in the created table above:
We can then create and insert data into a table. For example in the created table above:
  <USE sampledb;
  USE sampledb;
   
   
  CREATE TABLE playground (
  CREATE TABLE playground (
Regel 171: Regel 170:
     location varchar(25) check (location in ('north', 'south', 'west', 'east', 'northeast', 'southeast', 'southwest', 'northwest')),
     location varchar(25) check (location in ('north', 'south', 'west', 'east', 'northeast', 'southeast', 'southwest', 'northwest')),
     install_date date
     install_date date
  );</code>
  );
Insert the data into the preferred table:
Insert the data into the preferred table:
  <INSERT INTO playground (type, color, location, install_date) VALUES ('slide', 'blue', 'south', '2017-04-28');
  INSERT INTO playground (type, color, location, install_date) VALUES ('slide', 'blue', 'south', '2017-04-28');
  INSERT INTO playground (type, color, location, install_date) VALUES ('swing', 'yellow', 'northwest', '2018-08-16');</code>
  INSERT INTO playground (type, color, location, install_date) VALUES ('swing', 'yellow', 'northwest', '2018-08-16');
View the added data:
View the added data:
  <mysql> SELECT * FROM playground;
  <mysql> SELECT * FROM playground;
Regel 185: Regel 184:
  2 rows in set (0.00 sec)
  2 rows in set (0.00 sec)
   
   
  mysql> exit</code>
  mysql> exit

Huidige versie van 14 jan 2023 om 11:58

Menu WireGuard Mariadb

phpMyAdmin

# cd /var/www/html/
# curl -LO https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.tar.gz
# tar xf phpMyAdmin-5.2.0-all-languages.tar.gz
# ln -s phpMyAdmin-5.2.0-all-languages phpMyAdmin
# vi /etc/httpd/conf.d/phpMyAdmin.conf
==================================================
Alias /phpMyAdmin /var/www/html/phpMyAdmin
  
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off     
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

<Directory "/var/www/html/phpMyAdmin">
    AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None
    Options -ExecCGI -Includes +IncludesNOEXEC
    Require all granted
#    Require all denied
#    Require ip 10.0.0.0/24 (eigen ip-reeks)
    <FilesMatch "\.(inc|php)$">
        <If "-f %{REQUEST_FILENAME}">
            AddHandler "proxy:unix:/var/opt/remi/php81/run/php-fpm/www.sock|fcgi://localhost" .inc .php
        </If>
    </FilesMatch>
</Directory>
=================================================

Om gebruik te maken van phpMyAdmin moet je wel een database hebben.

Om deze te installeren doe je het volgende:

sudo dnf install mariadb-server mariadb

Dependency Tree:

Transaction Summary
================================================================================
Install  13 Packages

Total download size: 18 M
Installed size: 107 M
Is this ok [y/N]: y

Once installed, start and enable MariaDB the service:

sudo systemctl enable --now mariadb

Verify if the service is running:

$ systemctl status mariadb
● mariadb.service - MariaDB 10.5 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
     Active: active (running) since Sat 2022-07-23 10:05:47 CEST; 2s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 18153 ExecStartPre=/usr/libexec/mariadb-check-socket (code=exited, status=0/SUCCESS)
    Process: 18175 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir mariadb.service (code=exited, status=0/SUCCESS)
    Process: 20589 ExecStartPost=/usr/libexec/mariadb-check-upgrade (code=exited, status=0/SUCCESS)
   Main PID: 20448 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 12 (limit: 23441)
     Memory: 78.5M
        CPU: 268ms
     CGroup: /system.slice/mariadb.service
             └─20448 /usr/libexec/mariadbd --basedir=/usr

#2. Using MariaDB on Rocky Linux 9|AlmaLinux 9

Once installed MariaDB/MySQL databases can be used. First, secure the installation by setting a password for the root user.

sudo mysql_secure_installation

Proceed as shown: On MariaDB:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): Press_Enter
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
.....
Remove anonymous users? [Y/n] y
....
Disallow root login remotely? [Y/n] y
...
Remove test database and access to it? [Y/n] y
....
Reload privilege tables now? [Y/n] y
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Now login using the created root password:

$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.28 Source distribution

Copyright (c) 2000, 2022, 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>
mysql>  SELECT VERSION();

Sample Output:

Create a User and Database:

To create a user and database in MariaDB/MySQL, use the commands below replacing where required:

CREATE DATABASE sampledb;
CREATE USER 'test_user'@'%' IDENTIFIED BY 'Passw0rd';
GRANT ALL ON sampledb.* TO 'test_user'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;

After this, you will have a database named sampledb and a user test_user who can be accessed remotely created as swell.

Check the available databases:

<mysql> SHOW databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sampledb           |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> 

View users:

<mysql> SELECT User, Host FROM mysql.user;
+------------------+-----------+
| User             | Host      |
+------------------+-----------+
| test_user        | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)

mysql> 

To delete a user, use the command with the below syntax:

DROP USER 'username'@'host';

Create Tables

We can then create and insert data into a table. For example in the created table above:

USE sampledb;

CREATE TABLE playground (
    equip_id serial PRIMARY KEY,
    type varchar (50) NOT NULL,
    color varchar (25) NOT NULL,
    location varchar(25) check (location in ('north', 'south', 'west', 'east', 'northeast', 'southeast', 'southwest', 'northwest')),
    install_date date
);

Insert the data into the preferred table:

INSERT INTO playground (type, color, location, install_date) VALUES ('slide', 'blue', 'south', '2017-04-28');
INSERT INTO playground (type, color, location, install_date) VALUES ('swing', 'yellow', 'northwest', '2018-08-16');

View the added data:

<mysql> SELECT * FROM playground;
+----------+-------+--------+-----------+--------------+
| equip_id | type  | color  | location  | install_date |
+----------+-------+--------+-----------+--------------+
|        1 | slide | blue   | south     | 2017-04-28   |
|        2 | swing | yellow | northwest | 2018-08-16   |
+----------+-------+--------+-----------+--------------+
2 rows in set (0.00 sec)

mysql> exit