Home / Computer / 2 How to Create a Database with MySQL (Plus the Picture Guide)

2 How to Create a Database with MySQL (Plus the Picture Guide)

In creating a database, we will know the name MySQL. Yup, one of the relational database management systems (RDBMS) which is popular among programmers is one of the databases that are old. Initially, MySQL was created by Michael Widenius, before finally being acquired by Oracle and now has a brother named MariaDB.

Even so, MySQL is still widely used among application developers. In addition, some of the best IT campuses in Indonesia are still many that teach database management using MySQL. Therefore, you need to know how to manage the database using MySQL.

Now, of course before you manage the database, you need to create a database, right? Well, on this occasion, we will discuss how to create a database with MySQL. The ways that we will explain the following can also be used to manage the database on the web server or hosting that you rent. Let's look at the ways:

Creating a Database Through cPanel

cPanel is a web control panel provided by hosting services to make it easier for website owners to make arrangements via web display . In cPanel, there are various tools available that can be used to control and run websites, one of which is a tool for creating databases. If you use web hosting that uses cPanel, you can easily create databases through the menus that are available for setting up the database.

Its appearance is simple, making managing websites through cPanel easy enough to do, even by new users. In addition to creating new databases, you can also manage e-mail, upload files for your website, etc. via this cPanel.

Okay, let's follow the ways to create a database with mySQL via the following cPanel:

1 . Log in to cPanel from the website you have

2. Then click the "MySQL Databases" menu located in the "Databases" column

 how to create a new mysql database

3. Enter the name of the new database that will be created in the "New Database" column. Then, click the "Create Database" button to create a new database. Oh yeah, make sure the new database you created does not have the same name as the existing database.

 added a new database



4. Return to the previous page by clicking the "Go Back" button.

 created a database in cpanel

5. Add a new user (user) in the "Add New User" section. Fill in the user name in the "Username" column and the password in the "Password" column. Then, click the "Create User" button.

 how to create a database user

6. Click "Go Back" to return to the previous page.

 created a database user

7. If the database and user have been created, then add the user to the database that was created. In the "Add User To Database" section, select the user and database through the drop down menu that has been created. Then click the "Add" button to save the changes.

 added the user to the database

8. Check the "ALL PRIVILEGES" option. Then click the "Make Changes" button to save the changes.

 select privileges

Creating a Database Through Command Prompt [19659002] Besides going through cPanel, you can also create a MySQL database via command prompt commands on localhost. How to create a database with MySQL is very helpful when you want to develop a website without having to connect to the internet. You only need to install MySQL on the computer you are using, then you just have to run the command via the command prompt to create a MySQL database.

There are two kinds of various database software that you can use to create a database through Command Prompt. First with WAMPServer, and second using XAMPP or MariaDB. Here is the explanation:

a. WAMPServer

Before practicing this method, first install WAMPServer on your computer. You can download it via the following link . Once installed, you can just run WAMPServer and follow the way to create the following database in MySQL:

1. To open Command Prompt, you can go through the Run menu. The trick, press the Windows key + R on the keyboard, then type "cmd" (without the quotes), and press the Enter key.

 command prompt

2. After entering the Command Prompt window, type the command "cd c: wamp64 bin mysql mysql5.7.19 bin" (without quotes) and press Enter. This command must be adjusted to the installation location of the WAMP Server and the MySQL version installed on your computer. In this example, we installed it in the C: directory with MySQL version 5.7.19.

 access mysql at the command prompt

3. Type the command "mysql -u root" (without the quotes) and press the Enter key.

 access mysql

4. To create a new database, type the command "create database ". Then, press Enter.

 created a new database

5. To display a database list, type the command "show databases" and press Enter.

 displays the database

b. XAMPP

Next we will explain how to create a database with mySQL using MariaDB. MariaDB itself is a database developed from MySQL.

1. Install XAMPP on your computer.

2. After XAMPP is installed, run XAMPP and click the "Start" button in the "MySQL" line.

 created a database on mysql

3. To open Command Prompt, you can go through the Run menu. How, press the Windows key + R on the keyboard, then type "cmd" (without the quotes), and press the Enter key.

 command prompt

4. In the Command Prompt window, type the command "cd c: xampp mysql bin" then press Enter on the keyboard. This command must be adjusted to the installation location of XAMPP installed on your computer.

 entered the database

5. Type the command "mysql -u root" and press Enter

 create a database with cmd

6. To create a database, type the command "create database ", then press Enter.

 create a cmd database

7. To view the database that you have created, type the command "show databases" and press Enter on the keyboard.

 mysql database

Repetition

Of all the steps we provided above, the point is to create a database with mySQL, it's quite easy. You don't need to learn how to make database applications with certain programming languages. You will only study pure SQL and focus on the database side only.

To create a database in MySQL, the commands are as follows:

CREATE DATABASE cinema;

If successful, you can see the database that was created with the following command:

SHOW DATABASES;

Now, we will now explain a little about how to create a mySQL database table from the database that you have created. Why, why? One of the database components will be used to fill in the database that you have filled out. In this example, we will create several tables that will be used to handle the purchase of movie tickets using a database that has been created previously. The following scripts that you will enter into the database:

CREATE TABLE operator (1945 1945) id VARCHAR (20) NOT NULL,
name VARCHAR (50) NOT NULL,
password VARCHAR (100) NOT NULL ,
created_at DATETIME NOT NULL,
updated_at TIMESTAMP,
PRIMARY KEY (id)
);

CREATE TABLE movie (
id VARCHAR (20) NOT NULL,
VARCHAR (50) NOT NULL title,
TEXT description,
VARCHAR (50) rating NOT NULL,
production of VARCHAR (100) NOT NULL,
distributor VARCHAR (100) NOT NULL,
the duration of INT NOT NULL,
country VARCHAR (50) NOT NULL, created_at DATETIME NOT NULL,
updated_at TIMESTAMP,
PRIMARY KEY (id)
); ]

CREATE TABLE theater (
id VARCHAR (20) NOT NULL,
name VARCHAR (50) NOT NULL, created_at DATETIME NOT NULL,
updated_at TIMESTAMP,
PRIMARY KEY (id)
);

- foreign key: Teater_id
CREATE TABLE seat (
id VARCHAR (20) NOT NULL,
name VARCHAR (50) NOT NULL,
Teater_id VARCHAR (20 ) NOT NULL, created_at DATETIME NOT NULL,
updated_at TIMESTAMP,
PRIMARY KEY (id)
);

- foreign key: film_id, theater_id
CREATE TABLE schedule (
id VARCHAR (20) NOT NULL,
day VARCHAR (50) NOT NULL,
clock VARCHAR (20) NOT NULL,
INT NOT NULL price,
film_id VARCHAR (20) NOT NULL,
Teater_id VARCHAR (20) NOT NULL, created_at DATETIME NOT NULL,
updated_at TIMESTAMP,
PRIMARY KEY (id)
);
[19659002] - foreign key: operator_id, administrasi_id, kursi_id,
CREATE TABLE transaction (
id VARCHAR (20) NOT NULL,
operator_id VARCHAR (20) NOT NULL,
schedul_id VARCHAR ( 20) NOT NULL,
kursi_id VARCHAR (20) NOT NULL,
ju mlah_payed INT NOT NULL,
change INT NOT NULL, created_at DATETIME NOT NULL,
PRIMARY KEY (id)
)

If successful, you should see a list of tables has been created with the following command:

SHOW TABLES;

Our articles this time are about how to create a database with mySQL. Hopefully you can follow the tutorial that we provided in this article successfully. If you are interested in studying the database, read our article about the most complete SQL basic command on our site. Good luck and good luck.

Loading...

Check Also

Similar design and functionality but not Apple

The AirPods are still turning heads when it comes to true wireless earbuds, but there …