MySQL
MySQL is one of the most popular and widely used databases in the IT world. The reason for this popularity is without doubt this database's high performance and excellent scalability. This database management system is a relational database (RDBMS) based on SQL commands that covers most developers' needs.
One-Click Deployment
With Arvancloud Cloud Container ready-made applications, you can create a MySQL in 30 seconds with just one click.
In the database category, there are three MySQL-related database types:
- MySQL
- MySQL + phpMyAdmin
- MariaDB
Choose one of these three options based on your needs. Specify the resources you need, enter the application name and database password, and click Continue. Finally, after reviewing the invoice, click Create.
If all items and settings are entered correctly, your application should become active after about 30 seconds. To check the application's status and events, you can use the floating menu at the bottom of the page. For example, after the application becomes active, you can check its logs until the program starts inside the container by selecting your application in the Logs section of the floating menu.
Using MySQL
After the application starts, to test it you can enter the following command in the MySQL console section of the floating menu to connect and get started:
mysql -u root -p
After entering the password you set while creating the app, you enter the MySQL environment and can start creating new databases and the tables you need.
Connecting Applications in the Same Project
Applications set up on the Cloud Container can communicate with each other in several ways. Apps in the same project (namespace) can see each other locally through their service name and port.
There are two ways to check an application's service name:
- In the panel, in the application menu, on the Private Network tab
- Via the CLI, with the following command:
arvan paas get services
Connecting from Outside the Cluster with an IP Address
To connect to applications that aren't in the same namespace, first go to Public IP in the menu of the MySQL application you created and create a new IP. As you know, MySQL's target port is always 3306, and the connection port can be changed as you choose.
When connecting, you need to enter the port you specified in the client program.
Sample MySQL Queries
In databases, queries are used to work with data. For example, to create a new database or table and load or retrieve data in MySQL, you need to use various queries.
Creating a New Database
CREATE SCHEMA your_schema_name;
Creating a New Table
CREATE TABLE your_schema_name.your_table_name (
id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
email VARCHAR(100),
age INT
);
Inserting Data
INSERT INTO your_schema_name.your_table_name (first_name, last_name, email, age)
VALUES ('John', 'Doe', 'john.doe@email.com', 30);
Retrieving Data
SELECT * FROM your_schema_name.your_table_name;
For more details, you can use the MySQL guide.