*Managed Database* is a cloud service that provides a database engine. With a managed database, users no longer need to install and configure databases, including monitoring and maintaining server infrastructure.
Managed database services aim to make users, especially developers, focus on application development, without having to be bothered with managing databases.
DigitalOcean provides managed database services that support 3 database engines, namely MySQL, PostgreSQL, and Redis.
*Create a MySQL Managed Database*
Creating a managed MySQL database at DigitalOcean is very easy.
1. Click the menu *Create->Databases* 2. *Choose a database engine*, choose MySQL 3. *Choose a cluster configuration*, di sini saya memakai spesifikasi 1GB RAM, 1vCPU, 10GB disk, tanpa Standby Nodeshere I use the specifications of 1GB RAM, 1vCPU, 10GB disk, without Standby Nodes. *Standby Nodes* are the nodes that become the backup server, if a failure occurs on the main database server, the database service is switched to the standby node (automatic failover) 4. *Choose a datacenter*, here I use Singapore 5. *Choose a unique database cluster name*, enter a name for the cluster database 6. Finally, click the button *Create a Database Cluster*
Create a database cluster
*Connection to the Database Cluster*
After the database cluster is created, then securing the cluster database.
1. *Secure this database cluster*, in the field *Add trusted sources*, enter the name of the droplet, kubernetes cluster, tags, or IP address that is granted access to the database. Here I enter the ubuntu droplet that is in the same region and private network. Then click *Allow these inbound sources only* 2. *Connection details*, displayed connection information to the cluster database, and connections via public and private networks. Click *Continue* 3. *Next steps*, a command is displayed to perform a database migration. Click *Great, I’m done*
Database cluster overview
*Create User and Database*
Creating a user and database can be done directly in the tab *Users & Databases*.
1. *Add new user*, enter a new user 2. *Password encryption*, choose *Default – MySQL 8+* if the MySQL client support MySQL 8 password encryption and select *Legacy – MySQL 5.x* otherwise 3. *Password* is provided automatically
· *Add new database*, enter a new database name
*Connect to Database*
Previously the database cluster was set up so that it could only be accessed by the ubuntu droplet, therefore database access tests were run on that droplet.
Connect to database using the MySQL client, install the MySQL client on Ubuntu.[INPUT]
1 apt install mysql-client -y
Copy the command to connect to the database (flags) shown in the connection details.
Database connection details
Testing database access via the public network.[INPUT]
1 mysql -u webapp -pq99ke0axxhb09r5h -h db-mysql-sgp1-05094-do-user-4254703-0.b.db.ondigitalocean.com -P 25060 -D webapp
MySQL connection status via public network
Testing database access via private network.[INPUT]
1 mysql -u webapp -pq99ke0axxhb09r5h -h private-db-mysql-sgp1-05094-do-user-4254703-0.b.db.ondigitalocean.com -P 25060 -D webapp
MySQL connection status via private network
Show all databases.[INPUT]
1 show databases;
1 2 3 4 5 6 7 8 9 10 11 +——————–+ | Database | +——————–+ | defaultdb | | information_schema | | mysql | | performance_schema | | sys | | webapp | +——————–+ 6 rows in set (0.00 sec)
/Get a $100 free credit for every new account creation at DigitalOcean, *register via this link*/
Good luck ð