MySQLStudy ---- MySQL concept

I. database awareness

1. What is a database?

The database is stored in the data warehouse

1 stored data

"" " 
The first day learning the ways of storing data storage media is variable but the variable is the memory, the data in the memory after a power failure disappear, not permanently save
Obviously this will not work, such as the user just successfully registered username and password must be permanent. "
'"

2 stored data

"" " 
Use files to store data permanent storage can be achieved, but the file is stored on the hard disk, the first thing to consider is the efficiency of a reason why the application is inefficient because too many IO operations.
Also need to consider a problem :
? All the components can not be run on the same computer why the
performance of a computer always has an upper limit, for example, Taobao pairs 11 to 12 with a two-stage configuration of the server computer to do no matter how high are certainly too much, then how to do?
"" "

Extend your computer's performance

"" " 
1. Vertical extended
continuously improve the performance of the hardware undesirable 2. Scale (Distributed Computing) adding more computer programs are different components running on different computers offers the advantage: improved performance stability increase (pluggable type) is now a performance problem has been solved by a distributed manner but the distribution of these components, although they are still a whole on each computer that is operated or data files you copy the same program can access by default the only data but current computer. " '"









File access data on a different computer

"" " 
How can access files on other computers it?
Only one way, through the network through the network you want to tell the server what data sent over the network server in the data you want to you, have to need to use the socket, need support to a server and client program, the client program distributed to python python through a client application linked to the server to complete reading and writing data that is essentially a database on a TCP C / S structure program we can be our own to write such a set of software, but need to consider several issues 1.socket need without concurrency? must 2. Since it is complicated by also consider the security thread? need to file operation lock 3 is not request any computer link I have to accept it? not require user authentication 4. simple data on the local computer for data on the read speed is very slow hard disk seek time average latency addressing too slow! finding ways to improve the efficiency of data access, via index. now we know that to develop a The application must first solve the above four questions, but for every company, the development cycle is very important, not possible to develop applications and to spend a lot of time writing database programs, which have given rise to specialized database software manufacturers. write specialized database software.









 

2. Common Database

Relational Database

The database can establish relationships between data and data, the data is a man, he might be associated with a job data. The two sides can find each other through their own.

"" " 
Mysql free open-source support medium and large enterprises
in order to prevent mysql is closed source and worry about the ability to optimize the oracle
founder Widenius other from the kitchen stove developed mariaDB mariaDB fully compatible with mysql to use exactly the same   mysql life Bumpy Road has been sun - oracle acquisition oracle fees powerful closed-source distributed database   SQLServer Microsoft ecosystem windows system is too limited to support only   the DB2 IBM developed closed source database software often charged with IMB binding machine sales discounts Han

   



Non-relational

No relationship is not universal database limitations clearance between the respective data storage key value data, it will usually run in the memory, to increase the speed of data storage, the non-relational database used for caching, and with the use of a relational database.

"""
MongoDB
redis
memcache

 

Summary : We usually say that the database is a set of software services and client to file on the server-side action

3. Database concepts

"" "Data: recording status information for a digital object may be a character and the like as a sound image name = jerry record: a record for storing a typical feature of things equivalent line in the file, such as jerry, 180, man, Shuai table: essentially a file, create a table when in fact, create a file, you can see the whole can not put all the data into the same file in the database directory in order to reduce coupling facilitate the management of the data should be disaggregated? into different file library: is a folder DBMS: database management software is a server-side software database server socket:? running computer database management software developer in the company we care about which part is from the library-up "" "we need to be concerned about DBMS and server operation and maintenance are concerned

II. Installation mysql

1. Download the installation package

Download: https://dev.mysql.com/downloads/mysql/

Download time and provides an interface with the interface without using energy?

Server usually is not with linux system interface, and proficiency in SQL statements are usually the basic requirements of the interviewer

Here decompression installed version, to download the corresponding 32/64 compressed, decompression to the specified location.

2.mysql parse directory

"" " 
Bin executable file mysqld server main mysql no interface client data data file my-default.ini profile template



 

3. Start mysql server

Note: version 5.7 need to perform the initialization: mysqld --initialize-insecure

'' ' 
To start the server
1. Run the CMD, go to the bin directory via cd    
2. Do mysqld can start the server, if an error, then use administrator privileges to run CMD
It is at this time a socket server program is equivalent to do a little something like this:
start server socket and listens on port default binding current ip default port 3306 to start the client running mysql note that he is a socket program needs to connect to the server ip and port mysql -h ip -P port -uroot -p password is empty by default see the welcome screen then the link socket successful implementation of process analysis: ? this is the essence of what a command prompt is a input to accept an instruction and then sent to the server after it receives a command server parses out the data you want to send to the client that the question is certainly can not just write instruction, or the server does not know, we have to have a set of specifications that sql statement sql full-called structured query language, is all non-relational databases support language learning database is a large part of learning sql statement . After a successful login can execute the following command to see all the databases exist show databases; comparative data folder view


















Before talking about that command we think about it every time you want to use mysql had to first cd to this directory is very troublesome

How to solve it?

4. Environment Variables added

Find the installation directory, copy the path to fill the bin path in the system settings can be

Command Summary:

Start the server mysqld #

Start the client #mysql -h -P -u -p native abbreviated mysql -u -p

# Shut down the server

tasklist | findstr mysqld

taskkill /F /PID 8372

CMD can also exit

5. Registration System Services

Start-up and shut down the server needs to execute a command or not convenient enough how to do it?

'' 'Will be registered in the system mysql service mysqld --install Note that the default name registration service which is called mysql mysql the bin are two completely different things, a system service is a client executable file

To delete a service sc delete mysql (service name)

View system services run -> services.msc

Usually set to start automatically.

 

If the registration system service fails it may be because mysql unloading heavy equipment can be installed before you.

Interface version of the installation to fail before it could be installed, leading to the port occupied.

III. Modify the administrator password

Now the password is empty by default this is unsafe

Who put you up in case data is deleted how to do?

 

 

#change Password

Mysqladmin can be used in the case know the original password

mysqladmin is a program for managing the database, including modifying the password, data backup

Change Password: mysqladmin -uroot -p password 123 old password can ignore warnings

#decryption

In case you accidentally password forgotten how to do?

The company can not uninstall reinstall this password it certainly find places to store them, keep that client or server? Server, there is a memory that still drive it? Must be hard, being the case, there must be a file used to store password information

# 1 way

Delete data files used to record the user's password no problem simple and crude, however, this document is not only your account information as well as others account data as well as data related to the authorization so you better not do that! Then what are you thinking about, server authentication What is the nature of the user, the data is not read a file and to compare the data you enter, then can you tell I like this I said you do not read the server authorization file, you can!

# 2 way

Skip grant tables into the system to modify the grant tables recommend skipping this operation is server-related operations so we re-open the first turn off the server to re-open in time to tell it

1. Stop Service

2. Start the server and add the parameter ** mysqld --skip-grant-tables **

3. Use the client login server to perform modification command at this time do not need to enter a password update mysql.user set password = password ( "123123") where user = "root" and host = "localhost" **

4. Refresh rights flush privileges

The command line to restart the server to verify a new password

Four encoding settings

End execution using client \ s can view the settings information latin1 gbk server is the current default encoding. Client server is Latin GBK is very obviously garbled, we must ensure consistent coding!

 

How to Set Up

There my_default.ini he is the configuration file in the mysql installation directory, but he is not being used but a template file

If we want to write the configuration file yourself, so you need to copy a file called my.ini to write

Written in the format that we've learned over the configpaser module

[Section] option = value to be set to write the contents of the client's partition in mysql

To set the content server to write the partition in mysqld

mysql find my.ini file will automatically find the corresponding command to the installation directory at startup to load the title inside the settings

test

Add username and password in the configuration file is [mysql] user = "root" pasword = "123"

Note that: mysql mysqld will read the file, the client and the server we need to distinguish between the use of section

# Server Configuration section [mysqld] character-set-server = utf8

# Mysql client configuration section [mysql] default-character-set = utf8

# Client configuration remaining portion [client] default-character-set = utf8

Note: Modify the need to restart the server to configure mysqld

Five mac Configuration

First clear the same configuration file written in a way!

Different is that:

1.mysql mac default installation path can not be modified located: / usr / local use command + shift + g to go

2. my.cnf configuration file name needs to be placed when there can reinstall mysql mac when solving the problem can not be corrected completely remove mysql

sudo rm /usr/local/mysql

sudo rm -rf /usr/local/mysql*

sudo rm -rf /Library/StartupItems/MySQLCOM

sudo rm -rf /Library/PreferencePanes/My*

sudo rm -rf /Library/Receipts/mysql*

sudo rm -rf /Library/Receipts/MySQL*

sudo rm -rf /var/db/receipts/com.mysql.*

windows to remove the installation directory to remove system services

Guess you like

Origin www.cnblogs.com/tingguoguoyo/p/11005533.html