Recent Blog Posts

Creating A MySQL Database - Beginners Guide


At the current moment, many people are doing coding and programming and even taking part in many competitions and courses. But have you ever thought about learning Databases?, Well here I am with some database content to make you familiar with the MySQL database through this post. Well, MySQL is one of the most popular open-source relational database management systems, known for its speed, reliability, and ease of use. You can easily become familiar with the MySQL database in no time by following this guide. Setting up your first MySQL server is a very basic step for anyone looking to work with databases, whether you're a developer, data analyst, or just an enthusiast. In this post, we'll walk you through the process of setting up a MySQL server and using it to manage your data effectively using our Linux OS.


Before you can start using MySQL, you need to install it on your system real quickly and you can do so by following these simple steps-


1. Download MySQL: Visit the official website of MySQL (https://dev.mysql.com/downloads/mysql/) and download the MySQL Community Server based on your operating system or you can also install it the common way using apt.


2. Installation: Run the installer and follow the on-screen instructions to complete the installation. You'll be asked to set a root password during this process.



3. Start the MySQL Server: After installation, you can start the MySQL server by using the command sudo service mysql start or sudo systemctl start MySQL by just going to your terminal.


Configuring The Server


You can also secure the MySQL installation which is recommended and then you can move to create a new user for yourself. You should remember that you should not use a root user as it is considered a really good practice and you can even face some errors when you choose the root user option. Instead, you can add your own custom user by editing its config file. Then, you can just create your user by prompting the following command -

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

and also, don't forget to grant the permissions to the user you have created just now.

GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost'

then you can just exit the MariaDB prompt by typing exit and giving it the command. 


Interacting With The Server


Now that MySQL is installed and configured, you can start using it:

1. Access MySQL Shell: To interact with MySQL, Just open the MySQL shell by running mysql -u username -p and entering your password when asked.

2. Create a Database: You can create a new database using the CREATE DATABASE statement. For example: CREATE DATABASE mydb;.

3. Select a Database: Use the USE statement to select a specific database: USE mydb;.

4. Creating Tables: You can define the structure of your data by creating tables. Use the CREATE TABLE statement to create tables with the desired columns and data types.

5. Inserting Data: To add data to your tables, use the INSERT INTO statement.

6. Retrieving Data: Not only that but Fetching data from your tables using the SELECT statement can also be done. You can specify conditions and filters to retrieve specific data.

7. Updating and Deleting Data: You can also use the UPDATE and DELETE statements to freely modify or remove existing records according to your own desire.



There are just a lot more things you can try doing with the Mysql database and it is a really interesting database to learn about and is in high demand. It can get you a really good, basic knowledge of databases. I would highly recommend you to learn it and it is also a total investment of time and you don't specifically need the UNIX-based operating system but for this post, we have talked about setting it up in the UNIX-based System.




Which Database would you prefer to learn first? Share your thoughts about it in the comments below!




Comments