最近搞黑苹果。。。所以把所有的系统重新装了一遍,导致很多环境都是重新部署, 所以整理了之前的一些资料,这篇是关于MySQL绿色版安装的地方。

一、绿色版安装

1. 下载MySQL 5.7,地址:http://dev.mysql.com/downloads/mysql/ (选择32位或者64位版本需根据自身PC情况)

2. 下载后解压,比如我的目录结构是:


mysql绿色版 密码_MySQL

 

3. 配置Path路径:系统属性 => 高级 => 高级 => 系统变量 => path后添加 F:\CSoft\MySQL-5.7\bin

4. 修改my-default.ini,此文件是初始化信息:

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = F:\CSoft\MySQL-5.7
datadir = F:\CSoft\MySQL-5.7\data
port = 3306
# server_id = .....


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
# !o>UZ!e(h6(m  初始化的密码


 

5. 系统管理员模式运行cmd 输入如下命令


C:\Users\LCF>F:          //切换到F目录
F:\>cd CSoft\MySQL-5.7\bin   //进入bin目录
F:\CSoft\MySQL-5.7\bin>mysqld --install   //安装MYSQL服务
Service successfully installed.  //提示服务安装成功
The current server installed: F:\CSoft\MySQL-5.7\bin\mysqld MySQL

F:\CSoft\MySQL-5.7\bin>mysqld --initialize --console  //根据配置文件初始化,此时会有一大堆消息,
(注意最后的消息:
2016-07-13T14:21:39.268917Z 1 [Note] A temporary password is generated for root@
localhost: !o>UZ!e(h6(m  )
后面这个是密码待会儿登录使用的。

F:\CSoft\MySQL-5.7\bin>net start mysql  //启动mysql服务
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

F:\CSoft\MySQL-5.7\bin>mysql -uroot -p  //登录mysql
Enter password: ************   //密码就是输入的密码

mysql> set password=password('123456');     //修改密码
Query OK, 0 rows affected, 1 warning (0.00 sec)

目前为止成功安装。


删除window中的mysql服务

进入“控制面板->管理工具->服务”查看才发现,虽然MySQL已经卸载了,但是mysql服务仍然残留在系统服务里。
又不想改服务名,改怎么办呢。
后来上百度搜索发现,只要在CMD里输入一跳命令就可以将服务删除:

sc delete mysql //这里的mysql是你要删除的服务名

这样一来服务就被删除了,进入服务里查看确实没有mysql服务了,OK重新安装数据库吧。



二、中文乱码修改


1. 从服务端进行修改



show variables like "%char%";



然后可能显示如下信息,注意红色部分,不同的用户可能实际情况不同,但是需要保证除了 filesystem为binary外,其他都为utf8:

+--------------------------+---------------+  
| Variable_name | Value |  
+--------------------------+---------------+  
| character_set_client | gbk |  
| character_set_connection | gbk |  
| character_set_database | utf8 |  
| character_set_filesystem | binary |  
| character_set_results | gbk |  
| character_set_server | utf8 |  
| character_set_system | utf8 |  
+--------------------------+-------------+


2. 通过如下SQL语句进行修改,全部设置为utf8即可:

#设置数据库编码信息
SET character_set_client='utf8';  
SET character_set_connection='utf8';  
SET character_set_database ='utf8';  
SET character_set_results='utf8';  
SET character_set_server='utf8';


3、SQL连接字符串加上?useUnicode=true&characterEncoding=utf-8

jdbc.url = jdbc:mysql://localhost:3306/bsframe?useUnicode=true&characterEncoding=utf-8


一般按照上述步骤后,就不会出现乱码了!

三、修改为任意用户可以连接

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;



这里的yourpassword 是你设定的密码,请自行修改。


Doing is better than nothing