MySql绿色版安装过程记录

时间:2023-03-09 13:24:11
MySql绿色版安装过程记录

作为程序猿,要多动手,周末趁着有空且笔记本刚刚装了系统,所以就配置了下绿色版的MySQL。

多动手,多动手,多动手。

多总结,多总结,多总结。

以下为正文:

一、下载MySQL绿色版:

1.这个地址:http://dx2.xiazaiba.com/Soft/M/MySQL_5.6.27_XiaZaiBa.zip

2.或者去官网也可以的。

二、下载下来后,解压(安装)后在所对应的目录如下图所示:

MySql绿色版安装过程记录

那么接下来步骤如下:

1.将"my-default.ini"修改为"my.ini".

2.将如下代码复制进去:注意修改basedir datadir 和 Server

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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.
#mysql根目录
basedir ="C:\Soft\MySql"
#数据文件存放目录
datadir ="C:\Soft\MySql\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
#服务端的编码方式
character-set-server=utf8
[client]
#客户端编码方式,最好和服务端保存一致
loose-default-character-set = utf8 [WinMySQLadmin]
Server = "C:\Soft\MySql\bin\mysqld.exe"

三、"注册服务"

打开控制台依次输入如下指令:

cd C:\Soft\MySql\bin
mysqld --install MySQL --defaults-file="C:\Soft\MySql\my.ini"
net start MySQL

1.第一条语句表示跳转到MySQL解压后的目录中的bin文件夹。

2.第二条语句是表示通过我们配置的my.ini 注册服务。

3.表示启动服务。此步完成后如果提示OK,那么启动成功。

注:如果缺少第一步很可能出现一些错误,包括但不限于:系统错误或者系统找不到指定文件。

PS:附件几句可能会用到的命令,如果安装出错,那么卸载MySQL的指令如下

mysqld --remove MySQL 

四、其他琐事

1.修改密码

mysqladmin -u {userName} -p password {password}

解释:{userName}为你的数据库密码,默认用户名为 root,{password}为你的密码,默认密码为空。如果为空什么也不需要输入直接enter。

接下来系统会再次提示你输入旧密码,然后输入一次新密码,再确认输入一次:

Enter password:
New password: ******
Confirm new password: ******

2.开启远程连接

update user set host = '%' where user = 'root';  

select host, user from user;

flush privileges;

a.第一步是更新

b.第二句是查询。

c.第三句是刷新使MySQL立刻起效。

如果出现了如图信息表示成功。

MySql绿色版安装过程记录

或者使用

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;   

说明:myuser为用户名,mypassword为密码

3.修改数据库编码值

show variables like '%char%' 

可以查看编码

如果觉得那个编码不符合你要求,可以修改:

SET character_set_XXXX =utf8

下图是我的编码值设定,仅供参考:

MySql绿色版安装过程记录

4.查看当前数据库信息

show variables like '%version%

PS:2015-11-14 重启后出现如下问题:

Access denied for user 'root'@'localhost' (using password: YES)

没搞定此问题。。。。结果重装试试!