当前位置: 移动技术网 > IT编程>数据库>Mysql > mysql 5.7.21 安装配置方法图文教程(window)

mysql 5.7.21 安装配置方法图文教程(window)

2018年02月07日  | 移动技术网IT编程  | 我要评论

window环境安装mysql5.7.21,具体内容如下

1. 从mysql官网下载免安装的压缩包mysql-5.7.21-winx64.zip

2. 解压到相应的目录(此处解压到f:\mysql-5.7.21-winx64)

3. 配置环境变量,将mysql的启动目录(f:\mysql-5.7.21-winx64\bin)添加到path中

4. 在mysql目录下(f:\mysql-5.7.21-winx64)创建my.ini文件,内容如下:

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

5. 管理员身份运行cmd

切换目录:c:\windows\system32>cd f:\mysql-5.7.21-winx64\bin 

生成mysql服务:

f:\mysql-5.7.21-winx64\bin>mysqld -install 
service successfully installed.

生成data目录:f:\mysql-5.7.21-winx64\bin>mysqld --initialize-insecure --user=mysql 

启动mysql服务:

c:\windows\system32>net start mysql 
mysql 服务正在启动 . 
mysql 服务已经启动成功。 

6. 登录数据库,修改密码(默认密码为空)

登录数据库:

c:\windows\system32>mysql -uroot -p 
enter password: 
welcome to the mysql monitor. commands end with ; or \g. 
your mysql connection id is 2 
server version: 5.7.21 mysql community server (gpl) 
 
copyright (c) 2000, 2018, 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> 

修改密码:

mysql> 
mysql> 
mysql> show databases; 
+--------------------+ 
| database  | 
+--------------------+ 
| information_schema | 
| mysql  | 
| performance_schema | 
| sys  | 
+--------------------+ 
4 rows in set (0.00 sec) 
 
mysql> use mysql; 
database changed 
mysql> update user set authentication_string=password("新密码") where user="root"; 
query ok, 1 row affected, 1 warning (0.00 sec) 
rows matched: 1 changed: 1 warnings: 1 
mysql> 
mysql>flush privileges; 

精彩专题分享:mysql不同版本安装教程 mysql5.7各版本安装教程

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网