The procedure for "using the AWS server" is written in 5 parts.
Please check the articles below.
① Initial setting of EC2 ② Create a database in the production environment ← Imakoko ③ Start Rails on EC2 ④ Set up the Web server ⑤ Automate deployment
There are the following types of databases.
・ Hierarchical database ・ Network database ・ Relational database
The most used of these is the relational database
Information can be organized and managed in the form of an Excel table.
And the software that manages this relational database
It is called ** Relational Database Management System (RDBMS) **.
One of the representative RDBMS is MySQL
And there is also a database called MariaDB
derived from MySQL.
"MariaDB" is open source software developed as a derivative of MySQL. Compatible with MySQL. Amazon Linux 2 is supposed to use MariaDB.
If you are using Amazon Linux 2, MariaDB can be installed from the "yum command".
Execute the following command in the terminal (in EC2)
[ec2-user@ip-***-**-**-*** ~]$ sudo yum -y install mysql56-server mysql56-devel mysql56 mariadb-server mysql-devel
Use the "systemctl command" to start the database.
Execute the following command in the terminal (in EC2)
[ec2-user@ip-***-**-**-*** ~]$ sudo systemctl start mariadb
Execute the following command to check if it can be started
[ec2-user@ip-***-**-**-*** ~]$ sudo systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running)since Sat 2020-02-29 07:00:11 UTC; 7s ago
Process: 5993 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 5957 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
If "active (running)" is displayed in green, the database startup is successful.
MariaDB installed with yum has the default user "root" You can access it, but no password has been set. You need to set a password.
Execute the following command in the terminal (in EC2)
[ec2-user@ip-***-**-**-*** ~]$ sudo /usr/bin/mysql_secure_installation
① When "Enter current password for root (enter for none):" is displayed, press the Enter key. ② When "Set root password? [Y / n]" is displayed, enter "Y" and press the Enter key. ③ When "New password:" is displayed, enter the password you decided (* Nothing is displayed on the screen, but you can enter it) ④ When "Re-enter new password:" is displayed, enter the same password (especially nothing is displayed on the screen, but you can enter it)
If "... Success!" Is displayed here, the password setting is complete. It is necessary to continue answering about detailed settings.
⑤ When "Remove anonymous users? [Y / n]" is displayed, enter "Y" and press the Enter key. ⑥ When "Disallow root login remotely? [Y / n]" is displayed, enter "Y" and press the Enter key. ⑦ When "Remove test database and access to it? [Y / n]" is displayed, enter "Y" and press the Enter key. ⑧ When "Reload privilege tables now? [Y / n]" is displayed, enter "Y" and press the Enter key.
Settings are complete when prompted
Check if the password you set earlier can be used
Execute the following command in the terminal (in EC2)
[ec2-user@ip-***-**-**-*** ~]$ mysql -u root -p
You will be prompted to enter the password, "Enter password:". Enter the password you set earlier and press Enter. If the following is displayed, the database settings are complete.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 142
Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
You can exit by typing "exit".
that's all. Thank you for your hard work.
Continue → here
Recommended Posts