Data Structure In MySQL

  No comments

In computer science terms, a data structure is a way of storing, arranging and organizing data in computer storage media so that data can be used efficiently.
In programming techniques, data structures mean data layouts that contain columns of data, be they columns visible to users or columns only used for programming purposes that are not visible to the user. Each row of the set of columns is called a record. The width of the columns for data may vary and vary. There are columns whose width changes dynamically according to user input, and there are also fixed width columns. By this nature, a data structure can be applied to database processing (for example for financial data purposes) or for word processors whose columns change dynamically. Examples of data structures can be seen in spreadsheet files, data base (database), word processing, compressed imagery, as well as file compression with certain techniques that utilize data structures. [Wikipedia]



The structure of data storage on mysql is as follows.
                                                          Database

                                                               / \

                                                      Table      Table

                                                           /  \         / \

                                                       Field Field     Field Field

    The default database that belongs to root is mysql and test.
    To be able to see the database contained in mysql used commands

        mysql> show databases;

        Then it will be visible

           + ------------------------- +

            | Database |

           + ------------------------- +

            | mysql |

            | Test |

           + ------------------------- +

     To be able to use mysql database, use

          mysql> use mysql;



      To view the contents of the mysql database (the table contained in the mysql database)

          mysql> show tables;

(Note: If you have not selected the database used, then the command becomes

 mysql> show tables from mysql; )

          Then will be seen:





      To view the contents of the user table (fields contained in the user table)

         mysql> show fields from user;

        Then it will look:





  To view the contents of the data contained in the host field, user, password is used

    mysql> select host, user, password from user;

  To see all the data contained in the user field is used

    mysql> select * from user;

Root can add a new user on the mysql server

   Suppose root adds a user with a custom password on the host localhost.

   mysql> insert into user values ​​("localhost", "budi", password ("adi"), "Y", "Y", "Y", "Y", "Y", "N", "N", "N", "N", "Y", "N", "Y", "Y", "Y");

As root, you should always keep an eye on the data security issues in your server database, one of the ways to prevent accessing the database by others and using your database permissions is by giving passwords to users. Passwords stored in the user table should be stored in the form of encryption, therefore commands are used

                    Password ("adi")

In the above syntax, for users who do not have a password, the user should be removed, the syntax:

    mysql> delete from user where password = '';

Root can change its password in a way

    mysql> update user set password = password ("password_new") where user = "root";

For more details, see section E.


So a brief explanation of the data structure, apologize if there is a mistake, hopefully can be understood,

No comments :

Post a Comment