So this is my first time setting up a web server on my raspberry pi and the goal is to be able to take sensor readings from an arduino nano I have connected to my raspberry pi. These readings will be stored in a database and then will be pulled and displayed on a website continuously. I followed a Youtube tutorial on how to set up a LAMP stack and i was able to create the database through phpmyadmin. i could not install mysql.connector as it kept on returning an error that said no installation candidate. I installed mysqldb instead after seeing a command online that gave it as an alternative for mysql.connector. I have tried running my python code and it returns a can’t connect to server error. The first attachment is of the image of the error that is returned.
I am not also confident about how i set up my LAMP stack so below are the steps and commands i used
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt-get apache2 -y
- sudo apt install libapache2-mod-php
- cd /var/www/
- sudo chown pi: html
- sudo /etc/init.d/apache2 restart
- sudo apt install mariadb-server php-mysql -y
- sudo mysql
- CREATE USER ‘yourusername’@’localhost’ IDENTIFIED BY ‘yourpassword’;
GRANT ALL PRIVILEGES ON SensorData.* TO ‘yourusername’@’localhost’;
FLUSH PRIVILEGES; - sudo apt-get install phpmyadmin
- choose apache2 as webserver, configure database for phpmyadmin with dbconfig, option yes was chosen,and put in the password required.
- let apache configuration be aware of phpmyadmin’s config and to do this sudo nano /etc/apache2/apache2.config
- in the file type #Include phpmyadmin followed by Include /etc/phpmyadmin/apache2.conf
- save all changes and restart apache2
- logged in successfully to create my database on phpmyadmin
- sudo apt-get install mysqldb
- Then I run my python script only to get an error about not being able to connect to server
Is there something I have not done?
and how do I get it to work?
- I have tried installing mysql.connector several times and it returns no installation candidate error
- I also checked to see if the default port 3306 of mariadb was being used or otherwise and it is being used
beyond this i didn’t really have any more clues