Database (4-3)

Source: Internet
Author: User
Tags db2 mysql version create database install perl

 Databases (database, abbreviated DB)

Database technology is a very important technology in the field of computer application, it is produced in the the late 1960s, it is the newest technology of data management and also an important branch of software technology.

Simply put, the database is a repository of data, which is organized and stored according to a certain data structure (data structure refers to the organization or data), we can use the database to provide a variety of methods to manage the data in the database. A simpler image to understand, the database and the storage of our lives in the warehouse nature of the same, the difference is just storage of things different.

Database tables (table)

A data table is a very important object in a relational database, the basis of other objects, and a collection of two-dimensional arrays, which are used to store and manipulate the logical structure of the data. According to the classification of information.
A database may contain several data tables, each table is composed of rows and columns, record one data, the data table adds a row, each column consists of a field name and a collection of field data, the column is called a field,
Each column also has its own multiple properties, such as whether to allow Nulls, default values, lengths, types, storage encodings, annotations, and so on. For example

   

(data)

The information stored in the table is called data.

  There are 3 main components of a database system

1. Database System: Where data is stored.

2. Database Management System,dbms: Software for user management database.

3. Database application: A software supplement to the management database used to improve the processing power of the database system.

 History of the database (five phases)

1. The embryonic stage of the file system database system accesses data through files.          File system is the embryonic stage of database system, appearing in the 560 's, can provide simple data access function, but can't provide complete and unified data management functions, such as complex query. So when you manage less, simpler data, or simply access simple data, without complex operations, you use a file system
2. Hierarchical database Database system really started stage, the data is stored in the form of a tree-like structure, so also called the tree database.
3. Mesh database data is stored in a form similar to a network structure. Since the 1960s, the first generation database system (hierarchical model database system, network model database system) has come out, they provide a strong support for the unified management and sharing of data at this stage, the network model database due to its complexity, specificity, not widely used. In the hierarchical model database, IBM's IMS (Information Management system, information management systems) hierarchical model database system has been greatly developed, once became the largest database management system, with a huge customer base 4. Relational database The early 1970s, the relational database system began to embark on the historical stage, and has maintained a vigorous vitality. Relational database systems use Structured Query Language (structured query Language, SQL) as a database definition language DDL and Database operations language DML 5. Object-oriented database combining object-oriented method and database technology can make the analysis and design of database system accord with people's understanding of the objective world to the greatest extent. And it can effectively provide better database support for object-oriented programs.

⑴ for data sharingData sharing includes the ability for all users to access data in the database at the same time, as well as the ability for users to use the database in various ways and to provide data sharing. ⑵ reduce redundancy of dataCompared with the file system, because the database realizes the data sharing, thus avoids the user to establish the application file separately. It reduces the amount of duplicate data, reduces data redundancy, and maintains data consistency. data consistency and maintainability to ensure data security and reliabilityMainly include: ① security Control: To prevent data loss, error update and unauthorized use; ② Integrity Control: Ensure the correctness, validity and compatibility of data; ③ concurrency control: Enables multiple access to data during the same time period, and prevents abnormal interaction between users. Failure RecoveryThe database management system provides a set of methods to detect faults and repair faults in time, thus preventing data from being destroyed. The database system can recover the failure of the database system as soon as possible, it may be a physical or logical error. such as the wrong operation of the system caused by data errors.

In today's Internet, the most commonly used database model is mainly two kinds, namely relational database and non-relational data base.

1 Introduction to relational databases

(1) relational database : The complex data structure is attributed to a simple two-yuan relationship (i.e., two-dimensional tabular form).

(2) The current mainstream relational database: MySQL, Oracle, SQL Server, DB2 ...

Oracle is the world's most widely used database, the end of the last century with the advent of the network, Oracle launched 9i This version, I represents the Internet, fully support network reference.
10g,g is a grid grid, a database solution provided by Oracle to meet the advent of the "grid computing" era. MySQL is an open-source, free relational database. Because of its small size, fast speed, low total cost of ownership, especially the open source of this feature, the general development of small and medium-sized web sites have chosen MySQL as the site database. SQL Server Microsoft Corporation's relational database, general. NET platform will be preferred. DB2 is a series of relational database management systems produced by IBM, which serve on different operating system platforms.

2 Introduction to non-relational databases

(1) Background of the birth of non-relational database

non-relational databases have also become NoSQL databases, and NoSQL is meant to be "not just SQL." Rather than "no SQL", so NoSQL doesn't have to completely negate the non-relational database, But as an effective complement to the traditional relational database. NoSQL databases can perform unimaginable efficiencies and high performance in specific scenarios.

With the rise of Internet Web2.0 Web site, the traditional relational database in dealing with web2,0 website, especially for the large scale of the massive data, ultra-large-scale and high-concurrency microblogging, SNS type of web2.0 pure dynamic website has become inadequate, exposing a lot of difficult to overcome problems.

For example: Traditional relational database Io bottleneck, performance bottleneck are difficult to break through effectively, so there are a large number of specific scenarios, high performance and ease of use for the purpose of the function of the unique features of the database products. The data of the NOSQL (non-relational) class is born in such a situation and has developed very rapidly.

(2) A summary of NoSQL non-relational databases:
1, NoSQL is not a negative relational database, but as an important complement to the relational database
2, NoSQL for high performance, high concurrency, but the requirements for data consistency requirements are not high
3. NoSQL Typical product memcached (pure memory, k-v), Redis (persistent cache, k-v), MongoDB (Database of documents, Xml-json)

MySQL database: Is the Internet domain in one of the most important, by the vast number of users welcome open source relational database software, by the Swedish MySQL AB company development and maintenance. 2008. MySQL AB was acquired by Sun, and in 2009, Sun was acquired by the Big Guy Oracle (Oracle) in the traditional data database field, so MySQL database software is now owned by Oracle and becomes another database product of the traditional database domain. Oracle after the acquisition of MySQL, making itself in the business database and open-source software market share are the first position, such a pattern, caused a lot of people worry, this worry directly led to later MySQL branch database mariadb born in the development.

MySQL Development History

    • In 1985, several like-minded lads in Sweden (David Axmark, Allan Larsson and Monty Widenius) set up a company that was the predecessor of MySQL AB.
    • In 1990, TCX's customers began asking for SQL support for his API. It was proposed to use commercial databases directly, but Monty felt that the speed of commercial databases was unsatisfactory. As a result, he uses the mSQL code directly to integrate it into its own storage engine. Disappointingly, the effect was not very satisfying, so Monty ambitious and determined to rewrite a SQL support.
    • In 1996, MySQL 1.0 was released, and it was only for a small set of people, equivalent to internal publishing.
    • In October 1996, MySQL 3.11.1 was released (MySQL does not have a 2.x version) and was initially provided only in a binary version under Solaris. One months later, the Linux version appeared.
    • For 1999-2000 years, MySQL AB was founded in Sweden. Monty hired several people to work with Sleepycat to develop the Berkeley DB engine because BDB supports transactional processing, so MySQL has since started supporting transactions.
    • In December 2003, MySQL version 5.0 was released, providing features such as views, stored procedures, and so on.
    • January 16, 2008, Sun (Solar micro System) formally acquired MySQL.
    • On April 20, 2009, Oracle announced the acquisition of Sun computers at $9.50 a share and a total of $7.4 billion.
    • MySQL 5.5 was released in December 2010, and its main new features include semi-synchronous replication and support for Signal/resignal's exception handling, and most importantly, the INNODB storage engine has finally become the default storage engine for MySQL today.
    • June 18, 2013, Oracle revised the MySQL license agreement to remove the GPL. But then there was a message that it was a bug.

Why choose MySQL database?

(1) MySQL performance is excellent, service is stable, there are few abnormal downtime
(2) MySQL open source code without copyright restrictions, autonomy and low cost of use
(3) MySQL has a long history, community and user active, encountered problems can be solved
(4) MySQL software small size, easy to install and use, and easy to maintain, installation and maintenance costs are low
(5) MySQL brand reputation effect, so that enterprises do not have to consider the direct use
(6) MySQL support multi-use operating system, provide a variety of API interface, support multi-use development language, especially for popular languages have very good support

 

 MariaDB Introduction:

Appeared in 2009. MARIADB database management System is a branch of MySQL database, mainly maintained by the open source community, with GPL license. One of the reasons for developing this mariadb is that when Oracle acquires MySQL, MySQL has a potential risk of being closed, so the MySQL open source community uses branching to avoid this risk. Click to view Details

MARIADB The default storage engine is Maria, not MyISAM. Maria can support transactions, but transaction support is not turned on by default because transactional support has a performance impact. You can convert to the Maria engine that supports transactions by using the following statement. ALTER TABLE ' tablename ' Engine=maria transactional=1;

Windows Edition installation

Way One:

#1. Download: MySQL Community Server5.7. -https://dev.mysql.com/downloads/mysql/#2Extract the extracted packets from the flag network to the specified directory (e.g. D://mysql-5.7.20-winx64)#3Add environment variable "right-click Computer"--"attribute"-"advanced system Setting"-"Advanced"-"Environment variable"-"Find a row in the second content box with the variable named path, double-click"-"Append the MySQL Bin directory path to the variable value, split" C:\Program Files (x86) \parallels\parallels Tools\applications;d:\mysql-5.7. --winx64\bin#4. Initialize Mysqld--initialize-insecure#5. Start the MySQL service mysqld#6. Connect MySQL service MySQL-uroot-p Enter, have password input password, do not continue to enter decompression mode installation
Decompression Mode installation
PS: The production service must use the full path method # to make the MySQL Windows service, which executes this command at the terminal: " C:\mysql-5.7.16-winx64\bin\mysqld " --install# removes the MySQL Windows service and executes this command at the terminal:"c:\mysql-5.7.16-winx64\bin\mysqld " --remove'# start MySQL service net start MySQL (back without semicolon) # Close MySQL service net stop MySQL (without semicolon)
Production Services

After starting the MySQL service, open the Windows Task Manager, there will be a process called mysqld.exe run, so Mysqld.exe is the MySQL server program.

Exit Login: Quit or exit or \q;

Reference Blog: http://www.cnblogs.com/wangfengming/articles/7880595.html

Way two:

Nextnextnext....ps:mis way installation, will be installed more than the whole, easy to use.
recommended: mis-mode installation

Linux version

1,: http://dev.mysql.com/downloads/mysql/5.6.html#downloadsyou can also directly copy the 64-bit, download by command: wget http://dev.mysql.com/get/downloads/mysql-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz2, unzip # Unzip Tar-ZXVF mysql-5.6. --LINUX-GLIBC2.5-x86_64.tar.gz# Copy the extracted MySQL directory CP-R mysql-5.6. --LINUX-GLIBC2.5-x86_64/usr/local/MySQL3, add user groups and users # Add user group Groupadd mysql# add user MySQL to user group Mysqluseradd-g MySQL MySQL4, installation CD/usr/local/mysql/<br>mkdir./data/Mysqlchown-R mysql:mysql././scripts/mysql_install_db--user=mysql--datadir=/usr/local/mysql/data/MYSQLCP Support-files/mysql.server/etc/init.d/Mysqldchmod755/etc/init.d/MYSQLDCP Support-files/my-default. cnf/etc/my.cnf #修改启动脚本vi/etc/init.d/mysqld #修改项: Basedir=/usr/local/mysql/DataDir=/usr/local/mysql/data/MySQL #启动服务service mysqld start #测试连接./mysql/bin/mysql-uroot #加入环境变量, editor/etc/Profile so that you can command the export PATH from anywhere with MySQL= $PATH:/usr/local/mysql//Bin<br>source/etc/profile#启动mysqlservice mysqld start# close Mysqlservice mysqld stop# view running status service mysqld status5, Error5.1SQLyog connection, reported 1130 error, is due to no user rights to remote connection Resolution 1: Change the ' MySQL ' database ' user ' table ' host ' entry, from ' localhost ' to '%'. Use MySQL;Select 'Host'  fromUserwhereUser='Root'; Update userSetHost ='%' whereuser ='Root'; flush privileges; Resolution 2: Direct authorization grant all privileges on*. * to ' root ' @'% ' identified by ' Youpassword ' with GRANT OPTION;5.2some errors during installation-bash:./scripts/mysql_install_db:/usr/bin/Perl:bad Interpreter: No that file or directory resolved: Yum-Y Install Perl perl-develinstalling MySQL system tables ..../bin/mysqld:error whileLoading shared libraries:libaio.so.1: Cannot open sharedObjectfile:no such file or directory resolution: Yum-Y Install Libaio-devel
Linux Version installation

MAC version

Reference blog: http://www.cnblogs.com/wangfengming/articles/8509913.html

Above we introduced the database components, wherein the database management system can receive some commands, the data file to add, delete, modify, query and other operations. Then these commands are SQL.

SQL: (Structured query Language) is a Structured Query language abbreviation. is a language specialized in dealing with database management systems.

SQL language: Is the standard language of relational database, it is mainly used for accessing data, querying data, updating data and managing database system and so on.

Specifically, SQL can be divided into 4 parts:

    Data Control Language (DCL): Primarily used to control the user's access rights. Where the grant statement is used to add permissions to the user, the REVOKE statement is used to reclaim the user's permissions

   Data Definition language (DDL): DROP, CREATE, Alter, and so on; Database definition language. Primarily used to define databases, tables, views, indexes, triggers, and so on. The CREATE statement is used primarily for creating databases, creating tables, and creating views. The ALTER statement is primarily used to modify the definition of a table and modify the definition of a view. Drop statements are primarily used to delete a database, delete a table, delete a view, and so on.

    Data Manipulation Language (DML): INSERT, UPDATE, DELETE statement, database manipulation language. Mainly used to insert data, update data, delete data. The INSERT statement is used to insert data, and the UPDATE statement is used to update the data, and the DELETE statement deletes the data.

    data Query Language (DQL): SELECT statement. Used primarily for querying data.

#1. Operating folder add: Create Database db1 charset UTF8;        Check: show databases;        Change: Alter DATABASE DB1 CharSet latin1; Delete: Drop database db1;#2The operation file is first switched to the folder: Use DB1: CREATE TABLE t1 (IDint, nameChar); Check: Show tables change: ALTER TABLE T1 modify nameChar(3); ALTER TABLE T1 change name name1Char(2);    Delete: drop table T1; #3. Manipulate the contents of the file/Record add: INSERT INTO T1 values (1,'Egon1'),(2,'Egon2'),(3,'Egon3'); Check:Select* fromT1; Change: Update T1SetName='SB' whereId=2; Delete: Delete fromT1whereId=1; Empty table: Delete fromT1; #如果有自增id, the new data is still the same as the beginning of the last one before deletion. TRUNCATE table T1; The data volume is large, the deletion speed is faster than the previous one, and starts directly from zero, auto_increment means: self-increment primary key means: constraint (cannot be repeated and cannot be empty); Speed Lookup 
v file operation: Adding and deleting changes





Database (4-3)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.