🔥 Want to Master AWS & Java?
Subscribe to Ram N Java for more easy-to-follow technical tutorials!
SUBSCRIBE ON YOUTUBEIntroduction
MariaDB is one of the most popular open-source relational databases. In this guide, we will walk through the entire process of installing MariaDB on an Amazon EC2 Linux instance and show you how to set up a secure root password.
Step 1: Install MariaDB
First, connect to your EC2 instance via SSH. To check for available MariaDB packages and install the server, run these commands:
# Check available packages sudo yum list mariadb* # Install MariaDB Server sudo yum install mariadb-server
Step 2: Start and Enable the Service
After installation, you need to start the MariaDB service and enable it so that it starts automatically when the server boots up.
# Start MariaDB sudo systemctl start mariadb # Enable MariaDB to start on boot sudo systemctl enable mariadb
Step 3: Setting the Root Password
By default, MariaDB installs without a root password. To set a new password, follow these specialized steps:
- Stop the service:
sudo systemctl stop mariadb - Start in safe mode:
sudo mysqld_safe --skip-grant-tables & - Log in without a password:
mysql -u root - Update the password:
UPDATE mysql.user SET password=PASSWORD('your_new_password') WHERE User='root'; FLUSH PRIVILEGES; exit;
Step 4: Verify the Installation
Restart the service normally and log in using your new password:
# Log in with password mysql -u root -p # Once logged in, show databases SHOW DATABASES;
Conclusion
You have successfully installed MariaDB on your AWS EC2 instance! You now have a robust database ready to power your applications. Stay tuned for more tutorials on how to connect your Java applications to this database.
No comments:
Post a Comment