xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Need help with no permissions in PhpMyAdmin

Thu Sep 06, 2018 3:48 pm

Here are the steps I wrote for myself to follow, that I used to do my initial set-up.. (in case that was part of he problem some how?)


* Used Etcher to flash latest Raspbian Stretch to micro SD card.
* Added 'ssh' file to _root of SD card so I can connected via Putty/FTP..etc

Update Repositories:
------------------------------------------------
# sudo apt-get update


* Install Apache:

------------------------------------------------
-- sudo apt-get install apache2 -y //old line...difference? (apt-get)
# sudo apt install apache2 //new line


* Give permissions to Pi:

------------------------------------------------
# sudo chown -R pi:www-data /var/www/html/
# sudo chmod -R 770 /var/www/html/



* Change Default Web Page:
------------------------------------------------
# cd /var/www/html
# ls -al


** I test if the server is working by opening the web browser and typing the Raspberry Pi's IP address.
** I find out the IP address by typing: ifconfig in the terminal (or my router)



* Install PHP:
------------------------------------------------
# sudo apt install php php-mbstring

* Test PHP install:

//delete default apache index.html
# sudo rm /var/www/html/index.html

//create new index.php file in its place, with the following content:
# echo "<?php phpinfo ();?>" > /var/www/html/index.php

*** enabling PHP SHORT TAGS:
sudo nano /etc/php/7.0/apache2/php.ini //find short tags and edit/save config file (.ini)


* Install MySQL 7:
------------------------------------------------

# sudo apt install mysql-server php-mysql
** Type/Create root password when prompted //was never prompted to do so????

- Check install:
# sudo mysql --user=root


Add the wifi credentials:
------------------------------------------------------------------------------------------------------------------------------------------
* Create file on the card called wpa_supplicant.conf, which has the following inside:


ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
ssid="Your network name/SSID"
psk="Your WPA/WPA2 security key"
key_mgmt=WPA-PSK
}

Edit country=, ssid= and psk= with your information and save the file.
Use the 2 letter country abbreviation in CAPS (without this you will have no WiFi).
Use a pure text editor, not a word processor, to edit the wpa_supplicant.conf file.

*****************************************************************************************************



So all the above went fine..without much issue.. (followed an old wifi tutorial that disabled all DHCP ability..but thats been fixed now, and the steps updated above as well)

However.. there was ONE step I followed from this tutorials, how checking your MySQL install:

https://howtoraspberrypi.com/how-to-ins ... y-pi-lamp/

We will no delete the default mysql root user and create a new mysql root user, because the default one can only be used with Linux root account, and so not available for the webserver and php scripts.

To do so, once your connect to MySQL, simply run thoses commands (replace password with the password you want) :

Code: Select all

DROP USER 'root'@'localhost';
CREATE USER 'root'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'
So you now have a web server, connected to PHP and MySQL. That’s all it takes.

(On your nexts connections, you will be able to connect to mysql without using sudo, with the command:

Code: Select all

# mysql --user=root --password=yourmysqlpassword

Now.. I can 'login' into PhpMyAdmin.. with the credentials above root/password...

but I have NO PRIVILEGES to create a database.. or add tables..etc

and when I'm logged into PhpMyAdmin.. I see these 'pink' alerts.. saying phpmyadmin@local host has no permissions/denied..etc..

So my question(s) are:

1.) What is the correct process after installing MySQL to set up a new user account? Are you supposed to be deleting the default account? Why didnt setting the new user account and privs work? (I get a denied, need an account with creation permissions...etc)

2.) How do I fix my current situation so I can continue with my project.. (which needs a database populated with data to display the site)

Do I need to un-install MySQL? and re-install it? Starting over? How will this affect everything else that is currently installed/working? Any backlash? Negative consequences here? I am new to Linux (Raspbian).. and CLI in general here..

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Need help with no permissions in PhpMyAdmin

Thu Sep 06, 2018 8:37 pm

See my last response in your original thread (https://www.raspberrypi.org/forums/view ... 8#p1362276).
I noticed, when I followed what seem to be the same instructions as you did, that there was no semi-colon (;) printed after the last of the three MySQL commands ('GRANT ALL PRIVILEGES..."). If you entered it without the semicolon, the command would not be executed, and (if you then exited from the MySQL client) the newly created root user would be able to do nothing. I can't think of a way of getting out of this (if that is, indeed, what happened) without reinstalling MySQL, but I think that you can leave everything else alone. I believe that the following sequence will do this:

Code: Select all

sudo apt-get remove mysql-server mysql-client
sudo apt-get install mysql-server mysql-client

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Need help with no permissions in PhpMyAdmin

Thu Sep 06, 2018 9:18 pm

Thanks!

Man.. I hope you are right.. (although I feel rather silly not catching that... this whole Raspbian/CLI stuff is throwing me for a loop!.. and I'm not sure why!.. Like I shoudl have known/spotted a syntax error.. but I feel so 'green' here... Im constantly second guessing myself!)

I will remove MySQL
Reinstall MySQL

and then......

re-do the account removal/addition step(s) again?? (with included ; semi-colon!)

Anything else I need to do or be aware of perhaps?

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Need help with no permissions in PhpMyAdmin

Thu Sep 06, 2018 9:48 pm

xl97 wrote:
Thu Sep 06, 2018 9:18 pm
Thanks!

Man.. I hope you are right.. (although I feel rather silly not catching that... this whole Raspbian/CLI stuff is throwing me for a loop!.. and I'm not sure why!.. Like I shoudl have known/spotted a syntax error.. but I feel so 'green' here... Im constantly second guessing myself!)

I will remove MySQL
Reinstall MySQL

and then......

re-do the account removal/addition step(s) again?? (with included ; semi-colon!)

Anything else I need to do or be aware of perhaps?
That should work (with all the necessary semicolons in place!).

However, my recommendation would be to leave the default root user alone and create a new, additional 'superuser' for general use, as I set out in my last message in the old thread. A user with a blank password will not work with phpMyAdmin (in its default configuration), but you can use it directly with sudo and the MySQL client to sort things out if you subsequently do something to clobber your regular 'superuser'. Even if you do want to remove the original root user, I would very strongly recommend that you create and test a second superuser persona before deleting the original one.

fbe
Posts: 645
Joined: Thu Aug 17, 2017 9:08 pm

Re: Need help with no permissions in PhpMyAdmin

Thu Sep 06, 2018 10:24 pm

Code: Select all

sudo apt-get remove mysql-server phpmyadmin
sudo apt-get autoremove --purge
mysql-server is a "meta-package" only, the actual database packages wouldn't be removed. And without the --purge option mariadb would use the same messed database, that you are trying to recreate.

phpmyadmin needs to be removed too because it depends on the database packages. Install it, before you mess up the database root account. The phpmyadmin installation will fail, if you do it after recreation of the root@localhost account.

Not only the semicolon is missing in the grant privileges statement. Actually the statement should be:

Code: Select all

GRANT ALL PRIVILEGES ON  *.* to 'root'@'localhost' WITH GRANT OPTION;
Without the grant option, root cannot grant any privilege to other users.

Yes, it would be better to leave the root-user untouched and create another user with the same privileges like root@localhost. E.g:

Code: Select all

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON  *.* to 'admin'@'localhost' WITH GRANT OPTION;
Replace 'root' by 'admin' in any tutorial, you follow, when you are asked to login to mysql. And don't follow tutorials, that advise to run mysql_secure_installation.

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Need help with no permissions in PhpMyAdmin

Fri Sep 07, 2018 12:00 am

Thanks for the guidance here! :D

Just so I am clear.. I want to regurgitate all the advice.. and make sure I 'got it'.

Summary:

Un-install MySQL
Un-install PhpMyAdmin

* Make sure I -do- re-install PhpMyAdmin -BEFORE- I re-install MySQL? .......correct?

Re-install PhpMyAdmin
Re-install MySQL

(do I need to do any 'association' with PhpMyAdmin and the Database?)

To do the 'above'...

I need to SHH in and:

1.)
REMOVE MySQL:

Code: Select all

sudo apt-get remove mysql-server
sudo apt-get autoremove --purge
REMOVE PhpMyAdmin:

Code: Select all

sudo apt-get remove phpmyadmin
sudo apt-get autoremove --purge
Question:
* If I was trying to remove each individually.. are the above snippets correct?..

-OR-

REMOVE MySQL & PhpMyAdmin: (in one line)

Code: Select all

sudo apt-get remove mysql-server phpmyadmin
sudo apt-get autoremove --purge

2.)
(RE)INSTALL PhpMyAdmin:
* This needs to be done before re-installing MySQL *

Code: Select all

sudo apt install phpmyadmin
A.) The package will begin installing. You will be asked which web server is installed, choose apache2.
B.) Configure PhpMyAdmin’s database -- When prompted, choose Yes.

C.) Configure Apache to work with PhpMyAdmin

Code: Select all

sudo nano /etc/apache2/apache2.conf
D.) Navigate to the bottom of the file (keep pressing CTRL + V to jump page by page until you’re at the bottom of the file) and add the following new line to the file:

Code: Select all

Include /etc/phpmyadmin/apache.conf


3.)
(RE)INSTALL MySQL:

Code: Select all

sudo apt install mysql-server php-mysql
* Type/Create root password when prompted //never got a prompt?

* verify MySQL is working:

Code: Select all

 sudo mysql --user=root

**NOW**... instead of deleting the default user account.. just create a new one along side it:

Add New User with privileges:
** Line that gets you to query prompt (MariaDB)

Code: Select all

 sudo mysql --user=root

Code: Select all

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON  *.* to 'admin'@'localhost' WITH GRANT OPTION;
So I should now have everything back installed and associated/connected together? WITH a new user account to use with PhpMyAdmin that has correct permissions.

I can now connect to mysql with the command:

Code: Select all

sudo mysql --user=admin --password=password


Do I have all the above correct?

pfletch101
Posts: 629
Joined: Sat Feb 24, 2018 4:09 am
Location: Buffalo, NY, USA

Re: Need help with no permissions in PhpMyAdmin

Fri Sep 07, 2018 12:07 am

Thanks!

I think that the installation of Apache and its most common appendages (including MariaDB) on the Pi needs a sticky here somewhere that is kept updated. Things change, and there are a lot of traps for the unwary, and even some for the moderately wary!

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Need help with no permissions in PhpMyAdmin

Fri Sep 07, 2018 12:39 am

So is what I outlined above...correct?

Anything missing?

I am about to 'give it a go' right now...

still lots to do in my project here! :)

* boot to default webpage
* boot to fullscreen/kiosk mode

After that is complete.. (and while I await more hardware to arrive)..

I need to circle back to the 'front end' aspect f my project again.. (which is what all this webserver set up stuff is part of)..

While the 'Pi' will be driving/controlling my GUI/interface for the project (touch screen)... acting as a 'menu' of sorts..

once a selection is made (ie: form submits to itself).. I need to send (via PHP) some serial data out to a connected Arduino (Arduino will be connected to the Pi...not sure how yet)...

The Arduino parses this incoming serial data.. and does what it needs to do with it...

All the above has been accomplished.. (or at least roughed out enough to get a working example so far)..

But this has been on a Windows/PC machine.. and an install of WAMP...

I was told that on Windows.. I can only do 1-way serial communication

PHP to Arduino.....

but not Arduino >> PHP

I was told Linux/Mac/Raspberry Pi do not have this limitation and 2-way communication is totally possible...

So I lastly.. I need to figure out how I get my 'web page' to give a 'wait' message/page (text).. when the serial data is sent from PHP/Pi to Arduino...... and then go back to the menu screen once it receives a serial response FROM the Arduino back to the PHP/Pi...

Since I havent been able test on a workign system until now.. I am not clear how I need to go about it! LOL

PHP? (which is fine when I 'send' the serial data OUT to the Arduino... but not really for waiting for the response)...

Being server side... I'm thinking perhaps not? (not sure).. Maybe some Ajax instead? (more research is in my future!) LOL

xl97
Posts: 132
Joined: Thu Jan 12, 2017 3:34 pm

Re: Need help with no permissions in PhpMyAdmin

Fri Sep 07, 2018 12:57 am

The above posted regurgitation of your advice and commands worked perfectly.

I logged in without issue.. and I can and have created a new database.. (I'm assuming tables wont be an issue either!) LOL


I do have a remaining question still pertaining to this topic if you dont mind...

After I log in.. I see several 'pink' alert panels.. with message like:

* mysqli_real_connect(): (HY000/1698): Access denied for user 'phpmyadmin'@'localhost'

* Connection for controluser as defined in your configuration failed.


Do I need to add/create an account for: phpmyadmin'@'localhost somehow?


Perhaps within PhpMyAdmin now that I have access with permissions? Or is this something that perhaps needs to be done via SSH/CLI (terminal)?

Return to “Troubleshooting”