MySQL download and configuration

Brief introduction

MySQL is a relational database, developed by the Swedish MySQL AB, currently part of Oracle's product, MySQL is one of the most popular relational database management system, the role of Web applications is indispensable.

version

Currently there are 5.1, 5.5, 5.6, 5.7, 8.0 these versions (do not ask why no 6 and 7, which is why there is no question as window 9, iPhone Why not the same as 9), with the mainstream development should be 5.5, 5.6 , version 5.7.

download

Next, enter the subject, learning is always the first step is to download the installation. Here though MySQL is open source, but the official web site is in English, although we forty-six might perhaps have passed, but the non-native to see the full screen or get a headache. So here we are all of a sudden can not find the direction of the majority of white facilitate also the detail about how to download.
First click into the MySQL Community Edition download official website
https://dev.mysql.com/downloads/mysql/
If you click on the link above, will enter the following page, you will be able to choose the version number and compression fit models file download.

  • Select the version number, we chose version 5.6:
    Here Insert Picture Description
  • Here we select the compression package download and install by extracting:
    Here Insert Picture Description
  • The next step can not skip the landing, and then select the download path, direct download
    Here Insert Picture Description
  • Tips
    如果你不是点击上面的链接,自己访问的MySQL官网,你将会进行如下操作,才会到达上面的页面:
    选择downloads -> 选择community -> 选择MySQL Community Server
    Here Insert Picture Description
    名词区分:
    第一个 MySQL Enterprise ,企业版,收费,提供技术支持
    第二个 MySQL Community Server,社区版本,免费
    第三个 MySQL Cluster,这个单独是没法用的,要在1或2的基础上用。当然用来平衡多台数据库的。
    第四个 MySQL Workbench,这是个好东西,用来设计数据库的,是数据库的可视化操作界面

解压安装

下载完之后,将压缩包解压进你希望安装MySQL的目录,
打开解压后的目录应该包含有如下目录:
Here Insert Picture Description

  • 其中我们需要重点关注框出的两个文件夹以及一个文件:
    • bin: 存放编译好的工具
    • data:存放数据库数据的位置(就是我们数据库存放的地方)
    • my-default.ini:配置文件,接下来我们需要对其更改

更改配置文件

复制my-default.ini,然后重命名为my.ini。
(或者你下载的是5.7,其中没有data文件夹和my-default.ini文件,不要慌,新建一个txt文件,命名为my.ini同样有效)
复制以下内容进入my.ini文件,修改并保存:
(不知道怎么办的小白右击选择打开方式用记事本打开)

[mysql]
#设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3356端口          #默认一般是3306,我电脑里这个端口已经被占用了
port = 3356
#设置mysql的安装目录
basedir="D:\SDE\MySQL\mysql-5.6.44-winx64/"   #这里需要更改为自己的路径
#设置mysql数据库的数据的存放目录
datadir="D:\SDE\MySQL\mysql-5.6.44-winx64/data/"
#允许最大连接数
max_connections=200
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
#跳过密码验证
#skip-grant-tables

记得保存。

配置环境变量

右击我的计算机,选择属性,选择高级系统设置,选择高级,选择环境变量,
选择Path,点击编辑:
Here Insert Picture Description
新建一条变量,将你安装路径下的bin文件夹的路径复制进去,点击确定:
Here Insert Picture Description
千万不要忘了点确定!

初始化

  • 用管理员身份运行cmd:
    (这里拓展两种方法:)

    • 在开始菜单中找到cmd,右击以管理员身份运行
      Here Insert Picture Description
    • 右击开始菜单标志,选择以管理员身份运行powershell(一般都会自带Poweshell)
      Here Insert Picture Description

    进入管理员cmd界面后,先进入安装目录的磁盘,比如说我是D盘,输入D:并回车
    Here Insert Picture Description
    进入D盘之后,通过cd命令进入bin目录下面
    Here Insert Picture Description
    然后输入如下命令:mysqld --initialize,按enter键
    Here Insert Picture Description

    安装为系统服务

    在管理员模式下输入如下命令:注意这里用是5.6 路径为mysqld的路径
    (这里我用的是cmd管理员模式,不是powershell)

    sc create MySQL5.6 binPath= "D:\SDE\MySQL\mysql-5.6.44-winx64\bin\mysqld.exe" 
    

    Here Insert Picture Description
    win+R输入regedit打开注册表
    Here Insert Picture Description
    你会发现在图片中的目录下,找到刚添加进去的系统服务MySQL5.6
    (具体路径在图片中,可以依次打开目录找到,图中MySQL和MySQL5.7的系统服务为我之前已经添加好,不用管,因为我第一次装的是8.0,第二次装的是5.7,现在拿装5.6的写博客)
    Here Insert Picture Description

打开MySQL服务

  • 将my.ini文件中的skip-grant-tables配置项前面的注释拿掉
    目的是为了让跳过密码验证这段代码生效,记住需要保存
    Here Insert Picture Description

  • I remember after the restart mysql service
    can use the command line to restart the code
    can also be the start menu search for "service" application, open:
    Here Insert Picture Description
    find MySQL5.6 service, manually restart or right-click to open
    Here Insert Picture Description

  • Before the operation is the same cd to the bin directory
    execute mysql -P3356 -uroot -p, must pay attention here to add the port number, because the machine has a mysql5.7, so change the port:
    Here Insert Picture Description
    After the implementation of the above effect occurs, directly enter: the following screen appears, indicating success to enter:
    Here Insert Picture Description

    Modify the initial password

    Immediately after the previous step, we enter use mysql:
    Here Insert Picture Description
    and then enter the following code to change the password 123456 (customizable, provided that remember), and is persistent:

the SET authentication_string the User password = Update ( '123456'), password_expired = 'N', password_last_changed = now () the WHERE the User = 'root
`` `
- Re comment out the last line, restart MySQL, next time you can login password to login.

Guess you like

Origin blog.csdn.net/qq_37937830/article/details/92253120