MX on Linux: Difference between revisions

2,544 bytes added ,  11:21, 3 September 2020
m
Line 408: Line 408:
However, let me assume that you are happy to use '''PHPMyAdmin''' and I will describe how to install that. Start the install with <tt>sudo apt install phpmyadmin -y</tt>.  (Alternatively install a drill down package with <tt>sudo apt install adminer</tt> and I leave you to work out the commands needed after that).
However, let me assume that you are happy to use '''PHPMyAdmin''' and I will describe how to install that. Start the install with <tt>sudo apt install phpmyadmin -y</tt>.  (Alternatively install a drill down package with <tt>sudo apt install adminer</tt> and I leave you to work out the commands needed after that).


The PhpMyAdmin installer will ask some questions. Use your tab key to select <Yes> when it asks whether you want to configure with '''dbconfig-common'''.
The PhpMyAdmin installer will ask some questions. Use your tab key to select <Yes> when it asks whether you want to configure with '''dbconfig-common'''.  


Finally, we need to add the mysqli module to our php install, to restart apache, and to create symbolic link for the phpadmin installation to the server web root so can be seen in our browser and used there:
==Getting web and database servers ready for use==
 
We need to create a user for PhpMyAdmin (or adMiner or whatever) to access our database and another for Cumulus to use to access the database tables. At the moment our database access has the single root@localhost user we created when we installed MariaDB.  The initial password was set then, and we need to use it to get access to MariDB monitor where we can insert some SQL commands to create these two users. PhpMyAdmin on first start up will ask for username and password, thereafter it will use same log-in, let us create a user called 'admin' for it. The user name and password for the data base is set in MX using the [[MX_Administrative_Interface#MySQL_settings|MySQL_settings]] in the admin interface, let us create a user called 'weather'. Obviously, these names might not be what you use, but you can amend commands below accordingly. For each line with SQL, it must end with a semicolon (;) as shown.  The SQL lines have a prompt of a greater than symbol (>) while the command lines have a prompt showing current path. Note that "identified by" is followed by a password enclosed in single quotes.
 
<pre>sudo mysqli --user=root --password=InitialPassword
create user admin@localhost identified by 'PhpMyAdminPassword';
create user weather@localhost identified by 'MXPassword';
grant all privileges on *.* to admin@localhost;
grant all privileges on *.* to weather@localhost;
FLUSH PRIVILEGES;
exit;</pre>
 
Next, we need to add the mysqli module to our php install, to restart apache, to create a symbolic link for the phpadmin installation to the server web root so it can be seen (and used) in our browser, and we need to give the standard user (pi) ownership of the data files and the web pages:


<pre>sudo phpenmod mysqli
<pre>sudo phpenmod mysqli
sudo service apache2 restart
sudo service apache2 restart
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin</pre>
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
sudo  chown -R pi:www-data /var/www/html/</pre>




You can view any index.php or PHPMyAdmin web page in your browser by prefixing the address with your Pi URL e.g. '''http://192.168.1.xy/phpmyadmin''' where x and y are digits you look up as mentioned before where FTP of MX distribution was described. In this case you will see a PHP MyAdmin log on page where you type username and password (as you may not have added any other user yet, the user will be root).
You can view any index.php or PHPMyAdmin web page in your browser by prefixing the address with your Pi URL e.g. '''http://192.168.1.xy/phpmyadmin''' where x and y are digits you look up as mentioned before where FTP of MX distribution was described. In this case you will see a PHP MyAdmin log on page where you type username and password (as you may not have added any other user yet, the user will be root).
===Transferring database tables to your Pi=== 
If you have been using Cumulus before (and have a database) then you can use PhpMyAdmin on your old device to '''export''' out all the '''Cumulus tables as SQL''' in a zip file, FTP that zip file across to your Pi, use PhpMyAdmin to '''import''' that zip file. 
Providing you selected the right options for what SQL you created in your export, the import will contain SQL to create the tables and to insert all the rows into each Cumulus table on your Pi.
You might want to also '''export/import the PhpMyAdmin tables''' with your preferences in a separate zip, although these might need some extra transformations, as they are specific to a particular version of the database server (and the old device version may not match the MariaDB version on your Pi). Some PhpMyAdmin tables do change for different versions of the tool, so that too may make export/import of its tables more complicated.


== Restarting Apache ==
== Restarting Apache ==
5,838

edits