MySQL introduced, download and install

MySQL introduced

1.mysql version
dual licensed version of: Community Edition (free, functional enough nb a) and commercial (better, more features more powerful, but the charges, VIP, there are after-sales service, will reference and absorption Community Edition Some nb functionality, security and stability are the best, large hundreds of thousands), general NB open source software is licensed double
each version is divided into four versions in order to publish:
      Alpha version: generally only the company developed in-house use, not publicly, test, self-examination version
      Beta: general development is finished also finished testing version, generally does not appear large performance bug (generally, we do not, Ali, where to use this version, some new features, internal experts can be transferred, but also to evaluate new features of performance)
      RC version: some bug collection, etc. according to Beta testing after conducting a comprehensive version of
      GA version: software released version, there is no particular the demand must use the GA version, some companies pursue new feature uses the Beta version, this is one example.

2.MySQL product lines: (MySQL is written in C ++, before the oracle 9i version is written in C language, mainly after java)
the earliest, mysql accordance 3.x - 4.x - 5.x, etc. development, but in order to increase the competitive advantage of MySQL, as well as improve performance, reduce development and maintenance costs and other reasons, at the same time, more convenient and more accurate business users to choose the right product for their own version of the production environment, the development of MySQL 5.1 after the series version, re-planning for the three product lines.
    Article: 5.0.xx to 5.1.xx series product line introduction
    Article: 5.4.xx to 5.7.xx series product line introduction (mainstream: 5.5 and 5.6)
    Article: 6.0.xx to 7.1.xx product line series introduction

3. MySQL database software named Introduction

Mysql-5.6.42.tar.gz the version number to interpret:
      1. The first number is the major version 5, the file format is described. Version 5 Release all have the same file format.
      2. The second number 6 is the release level. Major version number and release level combined together they constitute the issuance serial number.
      3. The third data series in this release 42 is the version number is incremented with each new release. Usually you need to have selected the latest version issued after each update, the last number in the version string is incremented. If you added some new features or minor incompatibilities, version string of the second number is incremented. If the file format changes, the first number is incremented.
    We will add some general release said four versions of the above suffix, beta, alpha, rc version, ga version and so on, we have to give this example is not a suffix, equivalent to GA version

4.1 MySQL version selected recommendations
    1. Stable: Select the open source community version of the stable version GA version
    2 product lines: You can choose 5.1,5.5,5.6, 5.5 and 5.6 mainstream Internet companies, followed by 5.1.
    3. Select the MySQL database GA GA version for more than 6 months after release.
    A few months no major version of BUG fix the front and rear 4. To select, rather than a large centralized version of the BUG repair of
    5. The best back for a long time did not update the published version.
    6. The development, testing, operation and maintenance, DBA conduct their own local testing, it is best to be consistent and online versions of the worst but also compatible, so as a developer, you have to know which version of the company's database with
    7. As internally developed test database environment, running about 3-6 months.
    8. priority business non-core businesses to adopt new version of the database GA version of the software.
    10. want DBA expert advice, or technology is divided into good and to share with the group, using a real master spent GA easy to use version of the product

After the above steps, if there is no important function BUG or performance bottlenecks, you can start thinking about the back-end database software for any business data services.

Download MySQL installation, simple application and catalog description

1. Download and install

Two minutes to download and install the way for everyone to see, pay attention to this thing database is not the latest version does not care, care about is stable enough, and now the company is mysql5.5 and commonly used version of mysql5.6, now with mysql5.6 the version for everyone to show you:

The first method of installation download:

  mysql Download: https: //dev.mysql.com/downloads, if there is to download, see the operation:    imgselect in the following way: imgif you download the mysql installer file is named expansion .msi end, then when you install graphic tutorial on the installation in this manner below. img

imgSelect Custom mode here, because my computer is 64-bit, x64 choice  img  img

  img

  img

  img

  img

  img

  img

  img

At this point, the installation is complete. To add the path C: \ Program Files \ MySQL \ MySQL Server 5.7 \ bin system variables into the environment variable "Path"

Right-click on My Computer -> Click Properties  img

  img

  img

  img

Finally, open cmd, enter mysql -u root -p, and press Enter, if Welcome words appear, indicating that mysql installation was successful.   img

The second download installation methods:

mysql Download: https: //dev.mysql.com/downloads, if downloaded mysql official website zip archive, see operation, attention different download site of the first method above :  img

Then the following options to download, discover a zip archive right, zip compression after decompression can be used, the above msi also need to install it, the installation can be selected with a lot depends on the installation environment:  img

Click to download come:   imgthe installation after the download is complete: extract the compressed package MySQL, MySQL will download the compressed package extract to a custom directory. I put D: \ Program Files \ MySQL      img

In fact, it can be used after the completion of the 2 decompression, but for convenience, that is, when cmd start mysql, they do not add the full path, so add the environment variable, the bin folder added to the environment variable, bin this folder has mysqld server with a built-in mysql client, so after adding environment variables, in cmd can be directly used.    img

        img

    Such will mysql server (mysqld) and mysql carrying a client (for the user to test the machine, is also used in cmd window, called the client mysql, when the operation will be used to back)

    Then directly in the cmd window you can start the mysql server, and can be viewed from inside the Task Manager.    img

    And then start a cmd window to look at the use of mysql client, and then connect it to open the server, you can succeed.

    Connection command is: mysql -h server IP address -P (uppercase) 3306 (mysql server default port) -uroot-(user, user used here to measure the root) -p password. Note: If this direct input password, middle and front -p password with no spaces.

    Conduct their own tests in this machine, so the IP address of the server mysql native loopback address 127.0.0.1, in fact, if it is their test mysql server side of the machine, you can not write ip address and port, direct write mysql -uroot -p, but when connected to other computers mysql must write IP address and port, and can not connect to a remote mysql server computer with other root, and pay attention to the firewall on the mysql server whether to allow 3306 to be outsider connection, even if you want others to change the firewall settings to allow him 3306 port is connected, directly or turn off the firewall (not recommended for direct closed, when the test can be used), otherwise it will error.    img

ip address 127.0.0.1 addition to writing, you can also write localhost, or your own ip address of the machine, but write ip address of the machine when the server will your client considered external device, do not allow such landing .

When connected to the machine test, you can not write ip address and port    img

So far, it has been possible to connect and use the mysql database, but you find that shut down mysql server is too much trouble started when the direct input of the carriage return started the mysqld

There are two ways to close:

1. turn off the server through Task Manager:        img

2. Close to the server through the cmd command mysql        img

        img

It can be controlled by way of open mysql service system service on or off, you need mysql service will be added to the system services, look at how to make a system service: Open cmd window Note: You must open an administrator cmd window, find where the lower left corner of the circle, click, and then enter cmd, matching up the command prompt, and then right-click to open as administrator

        img

        img

Then enter mysqld --install service name (can give the service a name, directly behind this directive, can not write, there is a default, you can view the back.

 img

This will add a system service

Then + r win key operation to open the window, which system services to open the input list services.msc        img

You can see the mysqld service, if not to click on the refresh button        img

Select the MySQL service this one, you can just right-viewing capabilities, there are startup and shutdown function, you can start and shut down the MySQL service in the form of system services, this service is enabled by default, you can also set your own whether to automatically boot start of behavior and so on, left double-click the service to see the window below.        img

After adding a system service, in this start-up and shut down mysql service, you can use two commands in cmd window to get:

Start command: net start mysql

Close command: net stop mysql

And can not be reused mysqld instructions directly started. img

Also can be removed by instruction service just added: remove service command cmd is: mysqld remove

A brief summary of mysql installation:

#1、下载:MySQL Community Server 5.7.16
http://dev.mysql.com/downloads/mysql/

#2、解压
如果想要让MySQL安装在指定目录,那么就将解压后的文件夹移动到指定目录,如:C:\mysql-5.7.16-winx64

#3、添加环境变量
【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中找到 变量名为Path 的一行,双击】 --> 【将MySQL的bin目录路径追加到变值值中,用 ; 分割】
 
#4、初始化
mysqld --initialize-insecure

#5、启动MySQL服务
mysqld # 启动MySQL服务

#6、启动MySQL客户端并连接MySQL服务
mysql -u root -p # 连接MySQL服务器

#7、将mysql添加系统服务
    注意:--install前,必须用mysql启动命令的绝对路径
    # 制作MySQL的Windows服务,在终端执行此命令:
    "c:\mysql-5.7.16-winx64\bin\mysqld" --install
 
    # 移除MySQL的Windows服务,在终端执行此命令:
    "c:\mysql-5.7.16-winx64\bin\mysqld" --remove
    注册成服务之后,以后再启动和关闭MySQL服务时,仅需执行如下命令:
    # 启动MySQL服务
    net start mysql
 
    # 关闭MySQL服务
    net stop mysql

mysql simple demo

Create a my.ini (my.cnf) files in the mysql installation directory, write the following configuration, and then restart the server

[client]
#设置mysql客户端默认字符集
default-character-set=utf8 

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 
user = 'root'
password = '123'

[mysqld]
#设置3306端口
port = 3306 
# 设置mysql的安装目录
basedir=E:\mysql-5.6.45-winx64 
# 设置mysql数据库的数据的存放目录
datadir=E:\mysql-5.6.45-winx64\data 
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

View instruction character set encoding:

show variables like "%char%";
如下命令改变字符集:
mysql> SET character_set_client = utf8 ;  
mysql> SET character_set_connection = utf8 ;   
mysql> SET character_set_database = utf8 ;   
mysql> SET character_set_results = utf8 ;    
mysql> SET character_set_server = utf8 ;  

MySQL client complete instructions when connecting server

mysql -h 127.0.0.1 -P 3306 -u root -p

If the password is forgotten how to do?

1 停掉MySQL服务端(net stop mysql)
2 切换到MySQL安装目录下的bin目录下,然后手动指定启动程序来启动mysql服务端,指令: mysqld.exe --skip-grant-tables
3 重新启动一个窗口,连接mysql服务端,
4 修改mysql库里面的user表里面的root用户记录的密码:
    update user set password = password('666') where user='root';
5 关掉mysqld服务端,指令:
    tasklist|findstr mysqld
    taskkill /F /PID 进程号
    
6 正常启动服务端(net start mysql)

Three ways to change the password

方法1: 用SET PASSWORD命令 
    首先登录MySQL,使用mysql自带的那个客户端连接上mysql。 
    格式:mysql> set password for 用户名@localhost = password('新密码'); 
    例子:mysql> set password for root@localhost = password('123'); 
    
方法2:用mysqladmin  (因为将bin已经添加到环境变量了,这个mysqladmin也在bin目录下,所以可以直接使用这个mysqladmin功能,使用它来修改密码)

    关于mysqladmin的介绍:是一个执行管理操作的客户端程序。它可以用来检查服务器的配置和当前状态、创建和删除数据库、修改用户密码等等的功能,虽然mysqladmin的很多功能通过使用MySQL自带的mysql客户端可以搞定,但是有时候使用mysqladmin操作会比较简单。
    格式:mysqladmin -u用户名 -p旧密码 password 新密码 
    例子:mysqladmin -uroot -p123456 password 123  
    
方法3:用UPDATE直接编辑那个自动的mysql库中的user表 
    首先登录MySQL,连接上mysql服务端。 
    mysql> use mysql;   use mysql的意思是切换到mysql这个库,这个库是所有的用户表和权限相关的表都在这个库里面,进入到这个库才能修改这个库里面的表。
    mysql> update user set password=password('123') where user='root' and host='localhost';   其中password=password('123') 前面的password是变量,后面的password是mysql提供的给密码加密用的,最好不要明文的存密码,对吧,其中user是一个表,存着所有的mysql用户的信息。

    mysql> flush privileges;  刷新权限,让其生效,否则不生效,修改不成功。

Storage Engine

默认存储引擎 Innodb
查看存储引擎
show engines;

Introduction MySQL installation directory

Figure:      img

Which focus on look at data folder: If you can not find a file after the database or table to establish their own, may not be the data folder, connect mysql, enter the Variables like, Ltd. Free Join Show ` "%datadir%"; to view the data file storage path, find after the path to the next corresponding path not find this folder, it may be hidden, the hidden files are displayed on the list.        img

        img

Note: When using cmd it often requires the use of an administrator to run the cmd window, each requires its own right to select run as administrator, a lot of trouble, there are all methods of permanent solution, see the following:

1, go to "C: / Windows / System32" directory to find "cmd.exe":
      "Net start mysql" start MySQL service error, suggesting a system error 5 solution _MySQL

2, right-click Properties, select "Run as administrator":
      "Net start mysql" start MySQL service error, suggesting a system error 5 solution _MySQL

Permanent solution:

1. Create a "cmd.exe" shortcut:
 img

2, right click and select "Properties", select the "Shortcut", then select "Advanced", "Run as administrator" in the selection, then click "OK."
      img

After just open the shortcut you can run cmd as administrator of the!

: Comes with
instruction windows system view the system's default encoding:
under cmd window: The windows under cmd default encoding is GBK
want to see in the windows sqlite utf-8 Chinese need to perform chcp 65001 change the current page as utf-8 encoding
chcp command:
chcp 65001 is replaced by UTF-8 code page, right-click the title bar at the command line, select "properties" -> "fonts", modify the fonts True Type font "Lucida Console", and then click OK to property applied to the current window
chcp 936 can exchange the default GBK
chcp 437 American English
instruction linux system view the system's default encoding:
execute command: cat sysconfig i18n
result there is one: LANG = "zh_CN.utf8"

Guess you like

Origin www.cnblogs.com/sundawei7/p/11431675.html