从零开始的Linux运维屌丝之路,资源免费分享平台   运维人员首选:简单、易用、高效、安全、稳定、社区活跃的开源软件

03 - Windwods下安装MYSQL

发布:蔺要红08-03分类: MYSQL


下载地址:
https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62-winx64.msi
https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.62-winx64.zip
https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.45-winx64.zip
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.27-winx64.zip


下载后解压到D盘或者其他盘
把mysql解压后的bin目录的路径加入 WINDOWS环境变量  参考:D:\mysql-5.6.45-winx64\bin
# 进入cmd
d:                          # 进入D盘
cd mysql-5.6.45-winx64      # 进入mysql的解压目录
cd bin

#-------------------

5.7版本要在bin目录下手动初始化data目录
cd到bin目录下先初始化
1. mysqld --initialize-insecure自动生成无密码的root用户,
或者
2. mysqld --initialize自动生成带随机密码的root用户

#-------------------


mysqld -install    # 安装mysql  mysqld install
net start MySQL    # 启动mysql
mysql    # 第一次进入直接进入mysql无密码
mysql> use mysql;                # 设置mysql密码
update user set password=password("111111")  where user="root";

#5.7方式不同
update mysql.user set authentication_string=password('111111') where user='root' 

# 备注
以后进入mysql  使用mysql -uroot -p  输入密码
如果直接在cmd里mysql也可以进去,但是终端不可用


关于字符集问题

mysql> show create database day01;  #mysql默认使用的不是utf-8 而是 latin1 
+----------+------------------------------------------------------------------+
| Database | Create Database                                                  |
+----------+------------------------------------------------------------------+
| day01    | CREATE DATABASE `day01` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+------------------------------------------------------------------+
1 row in set (0.00 sec)

#修改 D:\mysql-5.6.45-winx64目录下的my-default.ini 文件问 my.ini(mysql5.7的配置)

[client]
port=3306
default-character-set=utf8
[mysqld]
#skip-grant-tables=1
port = 3306
basedir=D:\mysql-5.7.27-winx64
datadir=D:\mysql-5.7.27-winx64\data
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# 开启慢日志查询
slow_query_log= 1
slow-query-log-file=D:\mysql-5.7.27-winx64\data\mysql-slow.log
long_query_time= 3
#log_queries_not_using_indexes=on
early-plugin-load = ""
[mysql]
default-character-set=utf8


# 进入cmd重启mysql服务
net stop mysql
net start mysql
# 扩展:进入CMD  sc delete MySQL 卸载MySQL服务

mysql> show  create database day03;  # 字符集修改为utf8
+----------+----------------------------------------------------------------+
| Database | Create Database                                                |
+----------+----------------------------------------------------------------+
| day03    | CREATE DATABASE `day03` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+----------------------------------------------------------------+
1 row in set (0.00 sec)

 
温馨提示如有转载或引用以上内容之必要,敬请将本文链接作为出处标注,如有侵权我会在24小时之内删除!

欢迎使用手机扫描访问本站