AWS Amazon Web Services Cloud computing and PHP (Part 2) AWS Amazon Web Services Cloud computing and PHP (Part 2)

December 1, 2021

aws bash debian devops

Adding the Mysql DB and getting it running

Installing mysql isnt as simple as the rest of the LAMP stack. It is necessary to run the mysql_secure_installation command to setup the mysql password and the Update command to allowed login from the website for apps like Adminer. this article is a good explaination to why.

# install mysql

sudo apt-get install -y default-mysql-server
sudo apt-get install -y php8.0-mysql php8.1-mysql

#set the password and setup mysql
sudo mysql_secure_installation

# questions asked
# Enter current password for root (enter for none): 
# Set root password? [Y/n] Y
# 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

#test connection with the new password 
sudo mysql -u root -p

# to allow login for adminer login to mysql and run
# UPDATE user SET plugin='mysql_native_password' WHERE User='root';

# install adminer
sudo wget "http://www.adminer.org/latest.php" -O /var/www/html/adminer.php
sudo chown -R root:root /var/www/html/adminer.php
sudo chmod 755 /var/www/html/adminer.php

sudo /etc/init.d/mysql restart

This allows the user to login from the website using adminer and administer the DB tables.

Please visit this repo at github.com/allotmentandy/aws for shell scripts and files to run this code.


If you would like to contact me with this form on londinium.com, ilminster.net or via Twitter @andylondon