Acquaintance database (MySql)

 

I. Introduction

  1.MySql is a relational database.

  2 is an open source software,

  3 is a relational database management systems.

  4. The server operates under a client / server mode, or embedded system.

  Database Management Software Category:

  Divided into two categories:

  Relational: If db2, oracle, access, sql server, mysql, sql statement General

  Relational: mongodb, redis, memcache

  Can be simply understood as a relational database table structure requires, non-relational databases is a key-value store, the table structure is not

Second, the database Overview

  1. What is the record?

  Extracting a series of typical features of the transaction, consisting of a record described in a computer thing, the equivalent of a single line in the file, simply his record does not make sense, if we press the comma as the split, in turn define the meaning of each field, the equivalent of a table is defined as:

  In this case we know the meaning of specific data.

  2. What is a data table?

  Table and on the table above, as the following can continue to write to other people's information, save for the final form of the document, we usually can understand the data table is file.

Three, MySQL installation

  1. Download MySQL Address: http://dev.mysql.com/downloads/mysql/

  2. Extract, if you want to make MySQL installed in the specified directory, then it will move the folder after extracting the file to the specified directory, such as: D: \ mysql-5.6.45-winx64

  3. Add the environment variable,

Right [Computer] - "[Property] -" [Advanced System Settings] - "[Advanced] -" [Environment Variables] - "[find variable content box in the second row, called the Path, Double-] 
-> [bin directory path to the MySQL appended to the variable value} end configure the environment variables and restart the MySQL server cmd terminal

  4. initialize in the insecure---initialize mysqld
  5. the boot start the server MySQL mysqld #
  6. start the MySQL client and connect to the MySQL server mysql -uroot -p # connect to the MySQL server
  for unnecessary trouble, we can register as a service, before we start the server, enter cmd terminal mysqld --install, so we'll local service registration success,
to make everyone believe that the registration is successful or not, we run the computer management window input, and then click services and applications, and then click on the service, you can finally find MySQL in the service.
After successful registration, when the later start and shut down MySQL service, just execute the following command.
# Start MySQL service
NET Start MySQL
# shut down MySQL service
net stop mysql

login, password
  in the initial state, the administrator root, password is blank, the default login allowed from the machine localhost
  without a password, we can use the following command modify the password,
  the SET password for 'root' @ 'localhost' = password ( 'your password to be changed');
  in the presence of a password:
  mysqladmin -uroot -p123 password 456 # In this case the original password will be changed to 123 456 current password, this is the exit to modify the client can not be modified within the client.
  When we enter the wrong command can be used when \ c to cancel the previous command.

Crack the code
  to manually go to the local service has been launched in the server stopped
  1. Skip authentication user name and password, and start the server
  mysqld --skip-grant-tables to start the server, skip the grant tables
  2. Re-start as an administrator of an administrator window, enter the login command again, so that we will come in the form of a login without a password

  3. Modify the administrator password corresponding to the user

  4. Close the current server, in a manner re-validate the user name and password to start

  Exit row after killing a client, I am wrong here several times, killing must be conducted at the end of the program

  5. Start the server logs in again

  

  Profiles

  \ S view MySQL server is a simple configuration, the configuration file suffix usually are ini the end, MySQL comes with configuration files do not modify, re-build a ini the end of the configuration file, MySQL server will load at startup ini profile after modifying the configuration file server needs to be stopped, restarted. Remember, the new configuration file must restart the server

Fourth, the basic operation of the database

  Library, we can put it as simply a folder

    增   create database db1;

    Charles show create database db1; the establishment of a single file folder to take the investigation

    Change alter database db1 charset = 'gbk'; modified encoding

    Delete drop database db1; deleted library

  We usually appears in the table is a file, you need to specify when creating the table library, specify the library: use library name to view the current location of the library: select database ();

    增  create table userinfo(id int,name char);

    查   show table; 查看某个库下面的所以表   

      show create table userinfo; 查看表中id 和 name

      desc userinfo; 查看userinfo之下的列表

    改  alter table userinfo modify name char(32);

    删  drop table userinfo;

 

  记录  先创建一个库或者指定一个已经存在的库,切换到该库下,创建表,然后再操作记录

    create database db1;

    create table userinfo(id int,name char(32),password int);

    增   insert into userinfo values(1,'pan',123);  插入单条数据

      insert into userinfo values(1,'pan'123),(2,'dan',456);  插入多条数据

    查  select * from userinfo; 查询所有的字段信息

      select name from userinfo; 查询指定字段信息

      select id,name from userinfo where id=1 or name='pan'; 带有筛选条件的字段信息

    改  update userinfo set name='sb' where id=1; 修改数据的一个字段信息

      update userinfo set name='dsb',password=666 where id=1;修改数据的多个字段信息

    删  delete from userinfo where id=1;  指定删符合条件的数据

      delete from userinfo;  将表中的数据全部删除

    

  

 

 


  







 

  

Guess you like

Origin www.cnblogs.com/panshao51km-cn/p/11369886.html