The Series of MySQL -4- MySQL User Management - EP 04_01
HI Hi, Greetings!
Happy February
Hi Everyone,
Today, I would like to share with you an article about the fourth episode of Series of MySQL (MySQL Database), and the content is given below.
a. Create Database
b. Select Database
c. Show Databases
d. Drop Database
e. Copy Database
Create Database
A database is used to organize and store a collection of records. It lets us to organize data into tables, rows, columns, and indexes so that we can quickly access the information we need. We can quickly access and manage the records using the database.
A database in MySQL is implemented as a directory that contains all files in the form of a table. It allows us to establish a database in a variety of methods, the most common of which are:
MySQL Command Line Client
MySQL Workbench
MySQL Command Line Client
Using the CREATE DATABASE statement with the following syntax, we may create a new database in MySQL:
CREATE DATABASE [IF NOT EXISTS] database_name
[CHARACTER SET charset_name]
[COLLATE collation_name];
Parameter Explanation
The following are the parameter descriptions for the above syntax:
· database_name
It's the name of a new database in the MySQL server instance that should be unique. When we create a database that already exists, the IF NOT EXIST clause prevents an error.
· charset_name
It's a choice. It's the name of the character set that's used to hold all of the characters in a string. The MySQL database server can handle a wide range of character sets. MySQL uses the default character set if we don't specify it in the statement.
· collation_name
It compares characters from a certain character set and is optional.
Example
let's learn how to establish a database in MySQL. If we set the password during installation, open the MySQL console and write it down. We're now ready to build a database. We'll use the following statement to establish a database called "empdb":
mysql> CREATE DATABASE empdb;
It will look like the below output:
We can look over the freshly constructed database with the query below, which returns the database name, character set, and collation:
mysql> SHOW CREATE DATABASE empdb;
The following query can be used to check the database that has been created:
mysql> SHOW DATABASES;
We can view all the created databases on the server after running the above query.
Finally, we can access the database with the command below, which allows us to construct tables and other database objects.
mysql> USE empdb;
MySQL Workbench
It's a graphical user interface (GUI) tool for database architects, developers, and database administrators. SQL programming, data modeling, data migration, and complete administration tools for server configuration, user management, backup, and more are all supported by this visual tool. It enables us to construct new physical data models, E-R diagrams, and SQL queries (run queries, etc.).
To use this tool to create a new database, first-run MySQL Workbench and log in using the desired username and password. The following screen will appear:
To create a database, go through the procedures below:
1. Select the Schema menu from the Navigation tab. We can view all of the databases that have been built previously in this section. Right-click beneath the Schema menu and select Create Schema, or click the database icon (red rectangle), as seen in the following screen.
2. The new Schema window appears on the screen. Use the default character set and collation when creating a new database (for example, empdb1). Now, click the Apply button as seen on the screen below: click the Apply button:
3. A new popup window appears on the screen. Then press the Apply button.
4. On the screen, a new popup window emerges. To finalize the database construction, click the Finish button.
5. We can notice new databases in the Schema menu after successful database creation. If we don't see it, go to the Schema menu and click the refresh icon.
6. By picking the database and clicking the I button; we can get more information about it. Table, Triggers, Indexes, Users, and many more choices are displayed in the information box.
7. Although MySQL Workbench does not allow us to rename the database, we may add, edit, and delete tables and data rows from it.
You are welcome to like and leave feedback in the comment area.
Link:
EP 03_02:
EP 03_03:
EP 03_04:
EP 03_05:
Source:
https://www.w3schools.com/mySQl/default.asp
https://www.mysqltutorial.org/mysql-basics/
M M Zaheer Hussain
Stay Safe!