Learn to use database mysql

zhaozj2021-02-17  72

. Popular. Represents the Apache website server on the Linux platform; the combination of the MySQL database and Perl, Python, or PHP programming languages. At the same time it provides the C API, can be combined with GLADE / GTK , which can replace the VB Access / MS SQL Server combination of the Windows platform. This article introduces a simple usage of database mysql and its various tools.

First, why use mysql: MySQL is a high performance database because of the following reasons. It can compete with any similar products in the market.

l Speed. MySQL itself is not complicated. Http://www.mysql.com/information/crash-me.php You can find information about the data of Mysql and other database products.

l can be upgraded. MySQL can handle unlimited number of support and 500 million records at the same time

l Simply. MySQL's core is a small and fast database, and those who understand the work of the database are their effective work and preparation of advanced features.

l Value: MySQL is the free software that follows the GPL protocol, you can download and use it.

l Portability. Because MySQL is free software for open source, you can run all platforms, if you cannot run on your platform, you can modify, compile the source code.

Second, MYSQL is missing

Mysql is protected by permissions, not based on market. What can mysql and can't do what we need to be clear before use.

l Graphical Interface: MySQL begins to provide an interface similar to MS SQL Server, still in the test

l Transactions: MySQL does not support transaction processing, but in the release notes in May 9, 2000, mysql declared version 3.23.15 "Testive Support" Sleepy Software's Berkely DB database. Version 3.23.25 fully implements this feature.

l Storage procedure: MySQL has no stored procedure mechanism. There is a stored procedure mechanism in the "To DO" list of the mysql development group, which will be included in version 4.

l Trigator: The trigger is a program that typically exists in an embedded scripting language such as Zend or Python. There is a message saying that this trigger is applied to version 4 and uses the Zend script engine.

l Reference integrity: future support

l Record Level Lock: MySQL does not support recording level locking. In the future, it will improve, which is the power of open source.

L subqueries: MySQL does not support child query. But through the C language interface it provides, it can be easily compensated.

l View: MySQL does not support view. But it is in the to do list of the MySQL development group.

I clearly see the future meaning of MySQL for the platform application of turning to Linux.

Third, the installation of the mysql database system

Here, only the installation of the MySQL database system under the Linux system can be installed through the RPM package installation, and only the RPM mode is installed here.

Installation through the RPM package, you need the following three files:

1, mysql-3.23.25-1.i386.rpm This is a server part. It contains actual database servers that accept requests and returns

2, MySQL-Client-3.23.25-1.i386.rpm This is the client part.

3, mysql-wevel-3.23.25-1.i386.rpm. From this file, you need a C API file.

The installation process is as follows: First install the server section, and then install the client section, and finally the file needs to be installed in the C program.

1, install the server:

Type the following command: #RPM -IVH mysql-3.23.25-1.i386.rpm

2, install the client

Type the following command: # rpm -ivh mysql-client-3.23.25-1.i386.rpm

4, install C development file

Type the following command: #rpm -ivh mysql-wevel-3.23.25-1.i386.rpm

5, uninstall mysql: first need to turn off the server

#mysqladmin shutdown

#rpm -e -vv mysql-3.23.25-1

#rpm -e -vv mysql-client-3.23.25-1

6, install account management mysql server: Install from RPM. MySQL user account will be created automatically. This is a user who runs MySQL services.

Change the mysqladmin password: To enhance security, you need to change your password for the root user of MySQL, which can be done by the following two commands.

% mysqladmin -u root -p password 'new-password'

or

% mysqladmin -u root -h servername -p password 'new-password'

Fourth, start and stop Mysql server daemon

Using RPM installation, MySQL server Dameon automatically launches and stops, Redhat's system in /etc/init.d/mysqld's MySQL server script.

If you need to start MySQL Dameon for some reason, use the following command

% SAFE_MYSQLD -USER = MYSQL &

To turn off the MySQL server Dameon, send the submission:

% mysqladmin shutdown

V. Tools and procedures for use in mysql

In addition to the MySQL server (mysqld). The MySQL program group contains a lot of programs to manage the database and database server. These programs are installed when Mysql is installed via RPM. Isamchk and MyISAMCHK are tools for verifying and recombecing database tables and files. Mysqlaccess is used to authorize, change, and revoke user license permissions. MySQLADMIN is an advanced management tool such as creating a database and a shutdown database. MySQLDUMP is used to pour the data and backup tables in the emergency shutdown. It outputs data in the SQL INSERT statement, and the method used can feed back the output file to the MySQL server, and the row will also be loaded. MySQLIMPORT is an overall load tool, while mysqlshow displays information about database objects (if).

1. Isamchk: View and repair the destroyed table

If some unknown reasons is that the database table is destroyed, this tool is able to patch it. A data file that accommodates basic data is called an index sequential access method (ISAM) file.

Mysql uses the MyISAM file format as the default option in 3.23 and later. You need to use Myisamchk tools instead of isamchk. The ISAM table structure is replaced by myisam structure. ISAM will not be supported in the future. The following focuses on the Myisam file structure:

ISAM Old File Structure: Each table in the database is actually a combination of three files: *. Isd file contains data, *. The ISM file contains information about the data structure, such as a key and index, * .frm file contains a table Structure.

View three files in / var / lib / mysql / test_db / directory

TB1_BOOKS_1.FRM 88bytes

TB1_BOOKS_1.MYI 1024 BYTESTB1_BOOKS_1.MYD 8604 BYTES

* .frm and the old file structure are the same, *. Myi files and * .ISM files are consistent, and the * .myd file is in line with the old * .ISD file.

2. Myisamchk

This is the update version of ISAMCHK in MyISAM storage format. Its basic usage is as follows:

Myisamchk [options] TABLES..MYI

Use the following command to get the list of all options you can use in your system

3. MySQLACCESS This tool is the most discussion is the -howto command line. When you perform the command, you get an example of how to use this tool:

% mysqlaccess -howto

The method of use of mysqlaccess is quite simple:

mysqlaccess [host [user [db]]] options .. If there is no option, USER and DB must be provided. If you do not specify a host, use the local server.

4. MySQLADMIN

The conventional usage of this command is as follows:

MySQLADMIN [option] Command, the option is the standard UNIX command mode: -v For detailed description, -t = xx means the timeout time to connect to the server. Use command

% mysqladmin -? | More can see all lists. Command part is used for rules. Currently in the list is common in common Command

Command Description CREATE DB_NAME Create a database DROP DB_NAME called DB_NAME Delete Database Name Flush-logs Clear all log flush-privileges or relocad overload authorization form, or execute the same action command PING view MySQLD to start Shutdown to turn off database status to view the status of the server

5. MySQLDUMP

This is a tool for backup, transplant, or overloading the database. There are two types of command usage:

% mysqldump [options] Database [tables]

or

% MySQLDUMP [OPTIONS]. When using the second method, you must provide -Databases or -all-database option options

6. MySQLIMPORT

This is a large number of input tools of MySQL, which is similar to the BCP tool for MS SQL Server. It is the command line interface of the Load Data statement, the usage is as follows:

% mysqlimport [options] db_name file_name

7. MySQLSHOW

MySqlshow gives information about the database, table or column, which is the command line interface of the show statement

usage:

% mysqlshow [options] [database_name [Table_name [Column]]]

8. Myisampack

Myisampack can compress a MyISAM table to a relatively small space. He is a bit like Gzip, but it is running in the table. It runs on the .myd file and compresses it to a small size. After running myisampack, you can view the table, but you can't update the table.

All rights reserved, if you need to reprint, please indicate it.

转载请注明原文地址:https://www.9cbs.com/read-31297.html

New Post(0)