Tutoriel N° 2cf
Install mysql with phpmyadmin on ubuntu
1/ Make and execute the bash script in replacing YOUR_PASSWORD with the root password of your choice
shareannonce@shareannonce:~$ nano mysql_install.sh
#!/bin/bash
sudo apt-get update -y
sudo apt-get install apache2 -y
sudo apache2ctl configtest
sudo systemctl restart apache2
sudo ufw app list
sudo ufw app info "Apache Full"
sudo ufw allow in "Apache Full"
sudo mv /bin/df /bin/pydf
sudo mv /bin/dfanc /bin/df
sudo apt install debconf-utils -y
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password ROOT_MYSQL_PASSWORD'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password ROOT_MYSQL_PASSWORD'
sudo apt-get install mysql-server -y
sudo apt-get install php libapache2-mod-php php-mysql -y
sudo systemctl restart apache2
sudo apt-get install php-cli -y
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections
echo "phpmyadmin phpmyadmin/app-password-confirm password ROOT_MYSQL_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/admin-pass password ROOT_MYSQL_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/app-pass password ROOT_MYSQL_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | debconf-set-selections
sudo apt-get install -y phpmyadmin
clear
echo ""
printf "Do you want create a new mysql user ? [y/N] " | pv -qL 100; read pass;
if [ $pass = "y" ]
then
mysql -u root -pROOT_MYSQL_PASSWORD -e "CREATE USER 'USER_MYSQL_USERNAME'@'localhost' IDENTIFIED BY 'USER_MYSQL_PASSWORD';"
mysql -u root -pROOT_MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'USER_MYSQL_USERNAME'@'localhost' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;"
mysql -u root -pROOT_MYSQL_PASSWORD -e "FLUSH PRIVILEGES;"
fi
echo ""
printf "Do you want open phpmyadmin in firefox ? [y/N] " | pv -qL 100; read pass;
if [ $pass = "y" ]
then
sudo -u CURRENT_LINUX_USER -H sh -c "/usr/bin/firefox --new-window http://127.0.0.1/phpmyadmin"
else
exit 1
fi
sudo apt-get update -y
sudo apt-get install apache2 -y
sudo apache2ctl configtest
sudo systemctl restart apache2
sudo ufw app list
sudo ufw app info "Apache Full"
sudo ufw allow in "Apache Full"
sudo mv /bin/df /bin/pydf
sudo mv /bin/dfanc /bin/df
sudo apt install debconf-utils -y
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password ROOT_MYSQL_PASSWORD'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password ROOT_MYSQL_PASSWORD'
sudo apt-get install mysql-server -y
sudo apt-get install php libapache2-mod-php php-mysql -y
sudo systemctl restart apache2
sudo apt-get install php-cli -y
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | debconf-set-selections
echo "phpmyadmin phpmyadmin/app-password-confirm password ROOT_MYSQL_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/admin-pass password ROOT_MYSQL_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/app-pass password ROOT_MYSQL_PASSWORD" | debconf-set-selections
echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | debconf-set-selections
sudo apt-get install -y phpmyadmin
clear
echo ""
printf "Do you want create a new mysql user ? [y/N] " | pv -qL 100; read pass;
if [ $pass = "y" ]
then
mysql -u root -pROOT_MYSQL_PASSWORD -e "CREATE USER 'USER_MYSQL_USERNAME'@'localhost' IDENTIFIED BY 'USER_MYSQL_PASSWORD';"
mysql -u root -pROOT_MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO 'USER_MYSQL_USERNAME'@'localhost' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;"
mysql -u root -pROOT_MYSQL_PASSWORD -e "FLUSH PRIVILEGES;"
fi
echo ""
printf "Do you want open phpmyadmin in firefox ? [y/N] " | pv -qL 100; read pass;
if [ $pass = "y" ]
then
sudo -u CURRENT_LINUX_USER -H sh -c "/usr/bin/firefox --new-window http://127.0.0.1/phpmyadmin"
else
exit 1
fi
shareannonce@shareannonce:~$ sudo bash mysql_install.sh
3/ Open your browser:
http://127.0.0.1/phpmyadmin/
root
ROOT_MYSQL_PASSWORD
or
USER_MYSQL_USERNAME
USER_MYSQL_PASSWORD