Under Windows mysql-5.7.28 download, install, configure, tutorial

Recently the need to replace the version of mysql database, to write an article about the record

First, download the mysql database

Download mysql There are two, one is zip file, the other is msi installer
official 5.7 version zip file download page
official 5.7 version msi installer download page

I choose here 5.7.28-Windows64 bit

Click the lower left corner to start direct download

Thunder or IDM and other downloader, download will be faster

Two file after the download is complete

Second, install mysql database

I am here to use zip file installation, which is free to install and configure the contents of a little more

1. Unzip the installation file

  • Note: Unzip the path which do not appear in Chinese! ! !

2. Configure mysql

  • Double-click to enter to see the bindirectory

  • New dataFolder
  • And then create a text file, rename it my.ini(note that your computer may not display filename extension, my.inifile not on the datafolder)
  • Use a text editor to open my.inithe file, copy the following text into the configuration my.inifile
  • Modify the contents of your computer's configuration (be sure to remove all Chinese text row content)

  • Save and close the editor
[mysqld]
# 设置服务端使用的字符集为utf-8
character-set-server=utf8
# 绑定IPv4地址
bind-address = 0.0.0.0
# 设置mysql的端口号
port = 3306
# 设置mysql的安装目录(能看到bin即可)
basedir=D:\Applocations\64_mysql\mysql-5.7.28-winx64
# 设置mysql数据库的数据的存放目录(能看到my.ini文件的目录)
datadir=D:\Applocations\64_mysql\mysql-5.7.28-winx64\data
# 允许最大连接数
max_connections=2000
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 设置mysql以及数据库的默认编码
[mysql]
default-character-set=utf8
[mysql.server]
default-character-set=utf8
# 设置客户端默认字符集
[client]
default-character-set=utf8

3. Install mysql

  • Enter the bin/directory
  • In the address bar cmdand press Enter cmd to open a command line terminal

Chinese path can not contain the address, if not pay attention to the front, can be cut at the installation files to mysql path plain English

  • The installation commands in cmd terminal
# 安装命令
mysqld --install
# 卸载命令
mysqld --remove

Tip a successful installation

4. Initialize mysql

  • Continue initialization command in Terminal (you can initialize several times, but each must empty datafolder)
# mysql数据库初始化
mysqld --initialize --user=root --console
  • After execution is completed, it will give the mysql rootuser is assigned a random password, as

5. landing mysql

  • In the Terminal Services start mysql command
# 启动mysql服务
net start mysql
# 停止mysql服务
net stop mysql

  • Use the command mysql connection

    注:这个密码就是前面初始化mysql生成的随机密码

mysql -uroot -p密码
mysql -uroot -p

6.修改mysql的密码

默认随机密码也可以使用,但是太难记了,可以设置一个简单的密码

  • 执行下面的命令设置mysql的密码
# 设置mysql的密码
set password = password('密码');
# 退出mysql数据库 
exit

7.配置mysql的环境变量

  • 以此'此电脑'-->'属性'-->'高级系统设置'-->'环境变量'

  • 在系统变量下新建系统变量
变量名:MYSQL_HOME
变量值:D:\Applocations\64_mysql\mysql-5.7.28-winx64(能看到bin目录的mysql解压路径)

  • path下新增环境变量
%MYSQL_HOME%\bin

重新随意打开cmd终端,使用命令加修改的密码,就可以直接连接mysql了

三、mysql数据库添加用户

root用户是mysql数据库的超级用户,权限比较高,使用起来不安全,推荐新建用户,当然不新建也可以的

在终端里使用以下命令新建用户并授予权限

# 格式说明
grant 权限 on 数据库.表 to 用户名@连接的ip地址 identified by'密码';
# 实例,给密码是1234的test用户所有数据库的所有表的所有权限
grant all on *.* to test@'%' identified by'1234';

到此为止mysql安装完成,可以使用navicat连接数据库了

Guess you like

Origin www.cnblogs.com/leleplus/p/12077980.html