Step By Step Create a MySQL Database Via Command Line on Windows Terbaru 2019

Step By Step Create a MySQL Database Via Command Line on Windows.

Create a MySQL Database. This manual underneath will display you a way to Create a MySQL Database Via Command Line on Windows. It's clean to create a database, we have to know how to input SQL statements. By developing a database on your computer, you may be capable of collect, control, add, find the statistics saved for your laptop. Why we use MySQL in this academic to create a database. Because MySQL software is Open Source. And MySQL is the maximum popular Open Source SQL database control machine, is advanced, distributed, and supported through Oracle Corporation. Also, The MySQL Database Server could be very speedy, dependable, scalable, and smooth to use. MySQL Server works in customer/server or embedded systems. And many greater reasons why we use MySQL to create a database. Now, let we start our guide.

Database Programming.

  • These commands under are intended for creating a MySQL database on a Windows operating gadget pc.
  • Remember, each command ought to give up with a semicolon ( ;)

1. XAMPP

  1. Download and deploy Xampp server for your laptop.
  2. Now, open Xampp control panel.
  3. Then start MySQL.
    xampp control panel
    XAMPP manage panel
  4. Now, run Shell

2. Log In to the MySQL server.

  1. For the primary, we should log in to the MySQL server,
  2. To do this, we should enter a announcement to the command line with the subsequent command.
  • mysql -uroot
In this situation, we've special the user is root with u flag.if you have got detailed a password at your MySQL server, you should add p flag at the quit of command line, instance.
  • mysql -uroot -p****
which **** man or woman assign your password.at the other case you need to connect MySQL server to every other host, you must add h flag on the quit of command line.if you efficiently log in to MySQL server, You must see MySQL set off that looks very much like this:
  • mysql>

3. Create Database.

  1. To create a database with the call customers type the subsequent command:
  • create database customers;
If your database is correctly created, you'll see the subsequent message at MySQL activate.
  • Query OK, 1 row affected (0.00 sec)
If a database of the identical name already exists, then a brand new database will no longer be created and also you’ll get hold of this mistake:
  • ERROR 1007 (HY000): Can't create database 'customers'; database exists

4. Show Databases.

  1. To view the database you’ve efficaciously created actually issue the following command:
  • show databases;
The result will just like this.
show databases result
show databases result

5. Use Data Base.

  1. The use command is used when you have a couple of database on a MySQL server and want to replace between them. Statement : use [DatabaseName];  for example;
  • use customers;
The result will just like this.
  • Database modified.

6. Create Table.

  1. At this sections will show you a way to create a table interior clients database.
  2. Now we can create a customers table. The desk incorporates information showed on the picture beneath.
    table content - create MySQL table
    table content - create MySQL table
  3. Type the following command at MySQL prompt;
  • create desk customers(customerNumber int(11), customerName varchar(50), smartphone varchar(50), addressLine1 varchar(50), city varchar(50), country varchar(50), postalCode varchar(15), united states of america varchar(50));
If the desk effectively created, the SQL activate must go back with this result.
  • Query OK, 0 rows affected (0.28 sec)
Do the same steps to create some other desk.

7. Desc Table.

  1. DESC is short for DESCRIBE, this feature suggests the table structure.
  2. the announcement must see like this; ; desc desk name;
  3. Example ;
  • desc clients;
SQL activate should go back with this result.
  • +------------------+-------------+------+-----+---------+-------+
  • Field                     Type             Null   Key   Default   Extra  
  • +------------------+-------------+------+-----+---------+-------+
  • customerNumber int(11)           YES             NULL              
  • customerName     varchar(50)   YES             NULL              
  • smartphone                   varchar(50)   YES             NULL              
  • addressLine1       varchar(50)   YES             NULL              
  • city                       varchar(50)   YES             NULL              
  • state                     varchar(50)   YES             NULL              
  • postalCode           varchar(15)   YES             NULL            
  • us of a                 varchar(50)   YES             NULL              
  • +------------------+-------------+------+-----+---------+-------+
  • 8 rows in set (0.03 sec)

8. Alter Table.

  1. Alter desk used for alternate the table shape, there are many alternatives to apply adjust command.
  2. Now we will show add a primary key at the customers table.
  3. Now add a number one key at the customerNumber area.
  4. type the subsequent command at MySQL Prompt;
  • alter desk clients upload number one key (customerNumber);
SQL activate should go back with this result.
  • Query OK, 0 rows affected (0.63 sec)
  • Records: 0  Duplicates: 0  Warnings: 0
Now, back to the desc table command.sql activate should go back with this result.
alter table - create a primary key
alter table - create a primary key
You ought to see a PRI under the key column.

9. Input Data Into Table.

  1. This sections will give an explanation for to you a way to input information to the desk.
  2. The statements ought to appear to be this;
  • insert into table name (field1, field2, field3, ....fieldx) values (values1, values2, values3... Valuesx);
example.
  • insert into customers (customerNumber, customerName, smartphone,  addressLine1, metropolis, nation, postalCode, u . S . A .) values (1, 'Andy', '+62438999',  'royal avenue', 'kudus', 'crucial java', '59388', 'Indonesia'); 
SQL activate should go back with this result.
  • Query OK, 1 row affected (0.04 sec)
Remember, to go into facts should correspond to the records type, as an instance.
  • data type: Varchar = records must be enclosed in quotation marks.
  • data kind: Int (numeric) = Data may be without delay written.
  • data type : date = type with the following format (yyyy-mm-dd)

10. Show Table Data.

  1. How to expose records which is inserted into the desk.
  2. the statement is ;
  • select * from table;
example ;
  •  choose * from customers;
SQL activate should go back with this result.
show table data - mysql table
show table records - MySQL table
How to expose precise desk datathe announcement is ;
  • select field1, field2...filedx from table name;
example
  • select customerName, metropolis, united states of america from customers;
SQL activate should go back with this result.
show certain table data
show certain table data
Finish
Step By Step Create a MySQL Database Via Command Line on Windows Terbaru 2019Step By Step Create a MySQL Database Via Command Line on Windows. Create a MySQL Database. This manual underneath will display you a way to...

Artikel Terkait

Berikan Komentar

  1. Untuk menulis kode gunakan <i>KODE</i>
  2. Untuk menyisipkan kode ke dalam Syntax Highlighter gunakan <em>KODE YANG LEBIH PANJANG</em>
  3. Kode harus di-parse terlebih dulu agar bisa ditulis.
  4. Centang Notify me untuk mendapatkan notifikasi balasan komentar melalui Email.
histats