Page 1 of 2

MySQL Configuration

Posted: Tue Sep 24, 2019 2:53 pm
by El_Viejo
I intend to install Meteotemplate on my own server (LAN only), without Internet access. This server is hosted on a Raspberry Pi 3 (Raspbian Buster), which runs LAMP. (Uses Apache).
For the structure of folders and files, I followed the instructions of the Wiki.
I assume that this structure is the right one for an Apache server, because I get to show the script setup.php in Chrome and Chromiun browsers, from either of these two addresses
http://192.168.1.123/template/install/setup.php
http://meteomungi/template/install/setup.php

I run "Server Check" and it tells me everything is correct. But, when I run "Check MySQL", it returns this error message:
"Debugging error number: 2002
Debugging error: php_network_getadress: getadd info failed: Name or service not know."

Some data from the MariaDB/MySQL configuration for the root user.
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
+--------------------+

+----------------------+
| @@datadir |
+----------------- ----+
| /var/lib/mysql |
+--------------- ------+

Current user. root@localhost
Protocol version: 10
Connection: Localhost via UNIX socket
UNIX socket: /var/run/mysqld/mysqld.sock

I run phpMyAdmin with Username: phpmyadmin (this is the real user name I use) and Password: [mypassword].
From the SQL tab, I made two queries, with these results;
- hostname = meteomungi (matches my RPi host name)
- port = 3306
I don't know how to make other useful queries.

In the MySQL parameters I've done a lot of tests.
For Host address, I have tested
http://meteomungi
http://192.168.1.123 (my static IP)
http://localhost
http://127.0.0.1
The previous four, followed by 3306 (e.g. http://meteomungi:3306)
The previous four, followed by /template (e.g., http://meteomungi/template)
and a few more combinations, which I don't remember.

For User, I have tried: "root", "pi" and "phpmyadmin"

Pasword, I've always used the same password (all RPi server passwords are the same).

I have consulted dozens of websites and also in the forum, especially this threads:
http://meteotemplate.com/forum/viewtopic.php?f=49&t=456
viewtopic.php?t=1383
The "audum" user's website is working properly and, I think, it runs on a Raspberry Pi server, with Internet access.
I have reviewed several configuration files, both MariaDB and MySQL, but my knowledge of Linux is very limited and those of web servers, almost null. As a consequence, I still can't find the solution.

Re: MySQL Configuration

Posted: Mon Sep 30, 2019 3:12 pm
by LOBWX
if it's worth anything this is what I have in me config file on my PI 4

Code: Select all

$dbName = 'lobwx';
$con = mysqli_connect('localhost','my-user',my-'password',$dbName);

Re: MySQL Configuration

Posted: Tue Oct 01, 2019 9:14 am
by El_Viejo
Thank you very much for your interest in helping me solve my problem.
Unfortunately, my knowledge of Linux and web servers is very limited. I assume I have to run the sudo mysql command to get this terminal window.
MySql_Config_01.JPG
MySql_Config_01.JPG (64.38 KiB) Viewed 28872 times
Is it right or should I do everything from the root of the Raspbian terminal?
In either case, my doubts are as follows:
1.- I don't want to create a database. According to the Wiki, once the connection is checked, a database is created automatically. Is it necessary to create a database?
2.- I have created a "root" user of MariaDB with his "password". Is it necessary to create another user with a different password?
3.- The command to write must be:
con = mysqli_connect('localhost','root','yomismo');
or
con = mysqli_connect('localhost','root',my-'yomismo');


In any case, thank you very much for your help.

Re: MySQL Configuration

Posted: Wed Oct 02, 2019 4:10 pm
by LOBWX
El_Viejo wrote: Tue Oct 01, 2019 9:14 am 1.- I don't want to create a database. According to the Wiki, once the connection is checked, a database is created automatically. Is it necessary to create a database?
2.- I have created a "root" user of MariaDB with his "password". Is it necessary to create another user with a different password?
3.- The command to write must be:
con = mysqli_connect('localhost','root','yomismo');
or
con = mysqli_connect('localhost','root',my-'yomismo');


In any case, thank you very much for your help.
1. you can always come back and delete it.

2. I suggest that you should. To create a database user, type the following command. Replace username with the user you want to create, and replace password with the user's password:

Code: Select all

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
This command grants the user all permissions to all databases. with the exception of GRANT PRIVILEGES.

3. $dbName = 'lobwx';
$con = mysqli_connect('localhost','user','password',$dbName);

Hope it helps. You should probably use PhpMyAdmin to administer mysql/databases, makes it a lot easier. https://www.phpmyadmin.net/

Re: MySQL Configuration

Posted: Thu Oct 03, 2019 4:06 pm
by El_Viejo
Thank you very much for your help. I will follow your recommendations.

Re: MySQL Configuration

Posted: Sun Oct 06, 2019 5:52 pm
by El_Viejo
I have advanced, but I have problems with mysqli_connect.
Successfully, I created a new user (javier), with password (viva) and a database (deriodb).
I have done several tests with the connection command:

Code: Select all

con = mysqli_connect('localhost','javier','viva','deriodb');
con = mysqli_connect('localhost', 'javier', 'viva', 'deriodb');
con = mysqli_connect(localhost,javier,viva,deriodb);
In all cases the syntax error 1064 appears.
My PHP version is 7.3.9-1-deb10u1.
Can you help me discover the error? I'm a total novice and I have no choice but to abuse your patience. Thank you very much.

Re: MySQL Configuration

Posted: Sun Oct 06, 2019 6:09 pm
by El_Viejo
Here is a screenshot.
Error_syntax_01.JPG
Error_syntax_01.JPG (46.16 KiB) Viewed 28821 times

Re: MySQL Configuration

Posted: Sun Oct 06, 2019 7:08 pm
by LOBWX
All this goes into the /template/config.php file

Code: Select all

$dbName = 'deriodb';
$con = mysqli_connect('localhost','javier','viva',$dbName);

Re: MySQL Configuration

Posted: Sun Oct 06, 2019 8:35 pm
by El_Viejo
Sorry, but I can't find the file "config.php" in the folder "template".
Is it necessary to create it?
Thanks again.

Re: MySQL Configuration

Posted: Sun Oct 06, 2019 8:56 pm
by El_Viejo
I have read WiKi again and check that the config.php file is created after running for the first time the setup.php file located in /template/install.
Then, I assume that I must do the following operations:
1.- Run the setup.php file and save it.
2.- Edit the config.php file that will have been created and include these two lines

Code: Select all

$dbName = 'deriodb';
$con = mysqli_connect('localhost','javier','viva',$dbName);
Is that correct?
Excuse my clumsiness. Thank you

Re: MySQL Configuration

Posted: Mon Oct 07, 2019 2:31 am
by LOBWX
I was under the assumption you had already ran the setup.php. It's been at least two years since I installed my site. I kind of half remember. :roll:

Run the setup.php. Then report your progress/findings.

If I remember it pretty much does nearly everything, creates the database and more.

Re: MySQL Configuration

Posted: Mon Oct 07, 2019 4:29 pm
by El_Viejo
I apologize for my limitations with the English language.
In my RPi, with the Chromiun browser, from the static IP (192.168.1.50) , I write http://192.168.1.50/template/install/setup.php
and the Meteotemplate installation page opens.
I run "Server Check" and it tells me everything is correct. But, when I run "Check MySQL", it returns this error message:
"Debugging error number: 2002
Debugging error: php_network_getadress: getaddrinfo failed: Name or service not know."
Host address = http://localhost
User = javier or root
Password = viva or yomismo
database name = deriodb or empty
Thank you for your help

Re: MySQL Configuration

Posted: Mon Oct 07, 2019 5:26 pm
by LOBWX
Enter these commands and lets see what you get. This is what the info from my Mariadb shows.

Then we should be able to narrow down what to put in your /template/config.php

BTW do you have phpMyAdmin installed?

Code: Select all

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 938
Server version: 10.3.17-MariaDB-0+deb10u1 Raspbian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| lobwx              |
| mysql              |
| next               |
| performance_schema |
| phpmyadmin         |
| pws                |
+--------------------+
7 rows in set (0.001 sec)

MariaDB [(none)]> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> SELECT user FROM user;
+--------------+
| user         |
+--------------+
| oc_bettsr671 |
| pi           |
| oc_bettsr671 |
| phpmyadmin   |
| root         |
+--------------+
5 rows in set (0.001 sec)

MariaDB [mysql]>

Re: MySQL Configuration

Posted: Mon Oct 07, 2019 6:05 pm
by LOBWX
El_Viejo wrote: Sun Oct 06, 2019 8:56 pm I have read WiKi again and check that the config.php file is created after running for the first time the setup.php file located in /template/install.
Then, I assume that I must do the following operations:
1.- Run the setup.php file and save it.
2.- Edit the config.php file that will have been created and include these two lines

Code: Select all

$dbName = 'deriodb';
$con = mysqli_connect('localhost','javier','viva',$dbName);
Is that correct?
Excuse my clumsiness. Thank you
YES' on or about lines 13 or 14

Re: MySQL Configuration

Posted: Mon Oct 07, 2019 7:11 pm
by El_Viejo
Affirmative, I have phpMyAdmin installed.
I include it as an attachment are the results with sudo mysql and the three commands.
Thanks again

Re: MySQL Configuration

Posted: Mon Oct 07, 2019 7:31 pm
by LOBWX
ok now edit your /template/config.php
$dbName = 'deriodb';
$con = mysqli_connect('localhost','javier','viva',$dbName);

Then run the "Check MySQL" again with any luck you should have no errors.

Re: MySQL Configuration

Posted: Mon Oct 07, 2019 8:16 pm
by El_Viejo
Thank you for your patience and help. I'll try it tomorrow.

Re: MySQL Configuration

Posted: Tue Oct 08, 2019 7:07 pm
by El_Viejo
I have opened the page "setup.php", entered the data and saved it.
The file "config.php" has been created.
In this file, I only changed one data in "mysqli_connect", because the rest are correct. I changed 'http://localhost' to 'localhost' and saved it.
Then I tried to access again to the page setup.php and this message appears: "Unauthorized access. Please log in as an administrator first."
In the Wiki it says "Once the password is set on this page you will only be able to access this page after you login on the main site."
But, what is the main site?
Thanks

Re: MySQL Configuration

Posted: Tue Oct 08, 2019 7:13 pm
by LOBWX
http://yourdomain.com/template

example: http://lobwx.com/template

The admin login button is on the bottom of the page on the right.

Re: MySQL Configuration

Posted: Tue Oct 08, 2019 8:00 pm
by El_Viejo
Your patience is almost infinite. Thank you very much.
But write what you write,
http://192.168.1.50 or http://192.168.1.50/template
this is the page that appears. I think the error is in the paths

Re: MySQL Configuration

Posted: Tue Oct 08, 2019 8:21 pm
by LOBWX
Getting closer.

Code: Select all

$path = '/template/';
$pageURL = 'http://lobwx.com';
$baseURL = dirname(__FILE__)."/";
$adminPassword = 'mypass';
$updatePassword = 'mypass';
You also need to fix this, just localhost NO http://localhost

Code: Select all

$con = mysqli_connect('localhost','user','password',$dbName);

Do you not have a FQDN "domain name" .com , .net, or something?

Re: MySQL Configuration

Posted: Tue Oct 08, 2019 8:32 pm
by El_Viejo
I am using my RPi as a LAMP server, in a local area network, without Internet access.
I will try to modify the config.php file to $path = '/template/'; instead of $path = 'http://192.168.1.50/template/index.php'. It will probably work.
Tomorrow I'll tell you the result.
Thank you.

Re: MySQL Configuration

Posted: Tue Oct 08, 2019 8:34 pm
by LOBWX
De nada

Re: MySQL Configuration

Posted: Wed Oct 09, 2019 6:52 pm
by El_Viejo
I needed to repeat the whole process in another RPi.
I managed to start the Control Panel and register my Meteotemplate. Here is the proof :D :D
But "Table Create" displays this message: "Table was not created, please check your MySQL setup."
I'll keep investigating, but I'm sure I'll need your help. Do you still have patience?
In any case, thank you very much.

Re: MySQL Configuration

Posted: Thu Oct 10, 2019 2:00 pm
by LOBWX
You may want to check phpMyAdmin for the correct privileges on the the database you are using :?:

Capture.JPG
Capture.JPG (54.51 KiB) Viewed 28715 times