Deploy MySQL in Ubuntu server

Create a new ssh key in your computer.
Add the pub key to the AWS key pair directory.
Create new Ubuntu server and add access to port 3306 to it.
Connect to server using the same key.

Run the following commands in the server.

sudo apt update
sudo a…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Harrsh Patel

Create a new ssh key in your computer.
Add the pub key to the AWS key pair directory.
Create new Ubuntu server and add access to port 3306 to it.
Connect to server using the same key.

Run the following commands in the server.

sudo apt update
sudo apt upgrade -y
sudo reboot

Open ports for UFW.

sudo ufw allow OpenSSH
sudo ufw allow 3306
sudo ufw enable

Install NGINX

sudo apt install nginx

Check if NGNIX is working by accessing the public ipv4 address in the browser.

Allow NGINX for UFW.

sudo ufw app list
sudo ufw allow 'Nginx Full'

Setup MySQL.

sudo apt install mysql-server
sudo mysql

Exit if everything worked.

Install phpMyAdmin.

sudo apt install php-fpm php-mysql
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

Create new SQL user.

sudo mysql

mysql> CREATE USER '<user>'@'localhost' IDENTIFIED WITH caching_sha2_password BY '<password>';
mysql> GRANT ALL PRIVILEGES ON *.* TO '<user>'@'localhost' WITH GRANT OPTION;
mysql> exit

Copy phpMyAdmin configuration to NGINX.

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
sudo service nginx restart
sudo nano /var/www/html/index.php

Add the following lines

<?php
phpinfo();
?>
sudo service nginx restart
php -v

Check the PHP version from here.

sudo nano /etc/nginx/sites-available/default

Image description

Change the PHP version.

include fastcgi_params;
fastcgi_index index.php;
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
sudo service nginx restart
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

# Change the bind address to 0.0.0.0

sudo systemctl restart mysql

Change host of the MySQL user.

sudo mysql
mysql> SELECT User, Host FROM mysql.user;
mysql> UPDATE mysql.user SET HOST='%' WHERE User='<user>';
mysql> SELECT User, Host FROM mysql.user;

# % is the wildcard to connect from everywhere.

mysql> exit


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Harrsh Patel


Print Share Comment Cite Upload Translate Updates
APA

Harrsh Patel | Sciencx (2022-09-17T12:57:48+00:00) Deploy MySQL in Ubuntu server. Retrieved from https://www.scien.cx/2022/09/17/deploy-mysql-in-ubuntu-server/

MLA
" » Deploy MySQL in Ubuntu server." Harrsh Patel | Sciencx - Saturday September 17, 2022, https://www.scien.cx/2022/09/17/deploy-mysql-in-ubuntu-server/
HARVARD
Harrsh Patel | Sciencx Saturday September 17, 2022 » Deploy MySQL in Ubuntu server., viewed ,<https://www.scien.cx/2022/09/17/deploy-mysql-in-ubuntu-server/>
VANCOUVER
Harrsh Patel | Sciencx - » Deploy MySQL in Ubuntu server. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/17/deploy-mysql-in-ubuntu-server/
CHICAGO
" » Deploy MySQL in Ubuntu server." Harrsh Patel | Sciencx - Accessed . https://www.scien.cx/2022/09/17/deploy-mysql-in-ubuntu-server/
IEEE
" » Deploy MySQL in Ubuntu server." Harrsh Patel | Sciencx [Online]. Available: https://www.scien.cx/2022/09/17/deploy-mysql-in-ubuntu-server/. [Accessed: ]
rf:citation
» Deploy MySQL in Ubuntu server | Harrsh Patel | Sciencx | https://www.scien.cx/2022/09/17/deploy-mysql-in-ubuntu-server/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.