1.下载mysql安装包
进入mysql官网
选择Windows(x86,64-bit),zip Archive下载,如果你的电脑是32位的那就选择32位的下载,下载完成后解压缩到你指定的目录,我解压缩的目录是H:\mysql\mysql-5.7.19-winx64
2.配置mysql
在上面所说的目录新建my.ini文件
打开文件输入以下内容
[mysql]
default-character-set=utf8
[mysqld]
port = 3306
#mysql的安装目录,也就是你解压缩后所存放的目录
basedir=H:/mysql/mysql-5.7.19-winx64
#这儿需要改成你指定的数据文件的存储目录
datadir=H:/mysql/mysql-5.7.19-winx64/data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
完成上面的操作后,进入C:\Windows\System32,找到cmd.exe,以管理员身份运行,一定要以管理员身份运行,否则安装不能成功,打开命令窗口后,依次输入以下命令既可完成安装
C:\WINDOWS\system32>H:
H:\>cd H:\mysql\mysql-5.7.19-winx64\bin
H:\mysql\mysql-5.7.19-winx64\bin>mysqld install
Service successfully installed.
H:\mysql\mysql-5.7.19-winx64\bin>mysqld --initialize
H:\mysql\mysql-5.7.19-winx64\bin>net start mysql
The MySQL service is starting.
The MySQL service was started successfully.
H:\mysql\mysql-5.7.19-winx64\bin>mysql -?
mysql Ver 14.14 Distrib 5.7.19, for Win64 (x86_64)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
...
至此mysql安装完成
- 出现下面错误的解决办法
D:\MySQL\mysql-5.7.19-winx64\bin>mysqld --initialize
mysqld: [ERROR] Found option without preceding group in config file D:\MySQL\mysql-5.7.19-winx64\my.ini at line 1!
mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
按上面图片中的方法,将my.ini的编码修改为ANSI即可.
3.查看mysql的初始密码
打开你所指定的datadir的路径找到.err结束的文件,注意不要先启动mysql,否则是无法查看这个文件的,mysql一旦打开就会占用这个文件,用来输入运行过程中的日志信息,在Linux系统下与这个文件对应的文件是mysql.log
使用文本编辑器打开这个文件
root@localhost后面的内容即为mysql初始化后自动为我们生成的root初始化密码,然后启动mysql
H:\mysql\mysql-5.7.19-winx64\bin>net start mysql
The MySQL service is starting.
The MySQL service was started successfully.
登录mysql
H:\mysql\mysql-5.7.19-winx64\bin>mysql -u root -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
修改root密码,以及允许root远程连接,可阅读我的另一篇文章,Linux下以最简单的方式安装mysql5.7.19
彻底卸载mysql方法
- 删除mysql的安装目录
- 删除注册表
按win+R
输入regedit 回车
删除
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Eventlog/Application/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services/Eventlog/Application/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Eventlog/Application/MySQL
- 强制删除mysql注册在系统的服务
打开cmd命令行
输入
sc delete mysql
网友评论