文档章节

阿里云Windows Server 2012 安装绿色版MySQL

IceRainYWC
 IceRainYWC
发布于 2017/06/21 14:56
字数 1782
阅读 15
收藏 1

最近,在阿里云整了一个云主机环境,操作系统选择Windows,在搭建环境时,用安装版的MySQL遇到一个头疼的问题:MySQL安装完成后始终无法注册和启动服务(ps:还TMD无法卸载/(ㄒoㄒ)/~~),期间多次更换系统(Windows 2008、2003都尝试过)。

具体操作(假设MySQL路径为C:\Env\MySQL\MySQL Server):

1.下载和解压文件,在解压目录下创建my.ini文件,将如下内容拷贝到my.ini保存:

# MySQL Server Instance Configuration File
# ----------------------------------------------------------------------
# Generated by the MySQL Server Instance Configuration Wizard
#
#
# Installation Instructions
# ----------------------------------------------------------------------
#
# On Linux you can copy this file to /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options
# (@localstatedir@ for this installation) or to
# ~/.my.cnf to set user-specific options.
#
# On Windows you should keep this file in the installation directory 
# of your server (e.g. C:\Program Files\MySQL\MySQL Server X.Y). To
# make sure the server reads the config file use the startup option 
# "--defaults-file". 
#
# To run run the server from the command line, execute this in a 
# command line shell, e.g.
# mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# To install the server as a Windows service manually, execute this in a 
# command line shell, e.g.
# mysqld --install MySQLXY --defaults-file="C:\Program Files\MySQL\MySQL Server X.Y\my.ini"
#
# And then execute this in a command line shell to start the server, e.g.
# net start MySQLXY
#
#
# Guildlines for editing this file
# ----------------------------------------------------------------------
#
# In this file, you can use all long options that the program supports.
# If you want to know the options a program supports, start the program
# with the "--help" option.
#
# More detailed information about the individual options can also be
# found in the manual.
#
#
# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

port=3306

[mysql]

default-character-set=utf8


# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
port=3306
#skip-grant-tables

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Env/MySQL/MySQL Server/"

#Path to the database root
datadir="C:/Env/MySQL/MySQL Server/data/"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8

# The default storage engine that will be used when create new tables when
#default-storage-engine=InnoDB
default-storage-engine=MyISAM

# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=100

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=0

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
table_cache=256

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=18M


# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
thread_cache_size=8

#*** MyISAM Specific options

# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size=35M

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=25M

# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K

# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=256K


#*** INNODB Specific options ***


# Use this option if you have a MySQL server with InnoDB support enabled
# but you do not plan to use it. This will save memory and disk space
# and speed up some things.
#skip-innodb

# Additional memory pool that is used by InnoDB to store metadata
# information.  If InnoDB requires more memory for this purpose it will
# start to allocate it from the OS.  As this is fast enough on most
# recent operating systems, you normally do not need to change this
# value. SHOW INNODB STATUS will display the current amount used.
innodb_additional_mem_pool_size=2M

# If set to 1, InnoDB will flush (fsync) the transaction logs to the
# disk at each commit, which offers full ACID behavior. If you are
# willing to compromise this safety, and you are running small
# transactions, you may set this to 0 or 2 to reduce disk I/O to the
# logs. Value 0 means that the log is only written to the log file and
# the log file flushed to disk approximately once per second. Value 2
# means the log is written to the log file at each commit, but the log
# file is only flushed to disk approximately once per second.
innodb_flush_log_at_trx_commit=1

# The size of the buffer InnoDB uses for buffering log data. As soon as
# it is full, InnoDB will have to flush it to disk. As it is flushed
# once per second anyway, it does not make sense to have it very large
# (even with long transactions).
innodb_log_buffer_size=1M

# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and
# row data. The bigger you set this the less disk I/O is needed to
# access data in tables. On a dedicated database server you may set this
# parameter up to 80% of the machine physical memory size. Do not set it
# too large, though, because competition of the physical memory may
# cause paging in the operating system.  Note that on 32bit systems you
# might be limited to 2-3.5G of user level memory per process, so do not
# set it too high.
innodb_buffer_pool_size=47M

# Size of each log file in a log group. You should set the combined size
# of log files to about 25%-100% of your buffer pool size to avoid
# unneeded buffer pool flush activity on log file overwrite. However,
# note that a larger logfile size will increase the time needed for the
# recovery process.
innodb_log_file_size=24M

# Number of threads allowed inside the InnoDB kernel. The optimal value
# depends highly on the application, hardware as well as the OS
# scheduler properties. A too high value may lead to thread thrashing.
innodb_thread_concurrency=10

注意:需要配置修改的几项:①配置编码:default-character-set=utf8 ②配置MySQL安装目录:basedir="C:/Env/MySQL/MySQL Server/"和数据库文件data目录datadir="C:/Env/MySQL/MySQL Server/data/" ③配置引擎:default-storage-engine=MyISAM(如果配置InnoDB可能服务无法启动)

2.安装服务:
cd C:\Env\MySQL\MySQL Server\bin
mysqld --install MySQL
mysqld -install MySQL --defaults-file="C:\Env\MySQL\MySQL Server\my.ini"
3.启动服务:
net start MySQL
4.停止服务:
net stop MySQL
5.删除服务(只做备用,此步骤请跳过):
mysqld --remove MySQL
6.修改或设置密码:
mysql -u root -p   --##用空密码登录
show databases;
use mysql;
UPDATE user SET password=PASSWORD("123456") WHERE user='root';
FLUSH PRIVILEGES; --##【注意一定不要遗忘这句话,否则密码更改不能生效,刷新MySQL的系统权限相关表,第二种方法,就是重新启动mysql服务器】
QUIT
【注:如果出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)错误,编辑mysql配置文件my.ini,在[mysqld]这个条目下加入skip-grant-tables,保存退出后重启mysql。】
7.设置允许远程访问:
mysql -u root -p123456
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";
flush privileges;
mysql -h 127.0.0.1 -u root -p123456;   --##测试远程登录

 

最后特别注意:更改后,一定注意执行flush privileges;

© 著作权归作者所有

共有 人打赏支持
IceRainYWC
粉丝 13
博文 107
码字总数 48100
作品 0
石家庄
程序员
MSSQL · 最佳实践 · RDS SDK实现数据库迁移上阿里云RDS SQL Server

title: MSSQL · 最佳实践 · RDS SDK实现数据库迁移上阿里云RDS SQL Server author: 风移 摘要 至今,我们完成了SQL Server备份还原专题系列七篇月报分享:三种常见的数据库备份、备份策略的...

风移
07/18
0
0
阿里云部署discuz 9/20/2015(us time)

tool: ftp客户端 http://sourceforge.net/projects/filezilla/?source=typredirect 1 下载discuz最新版 http://www.discuz.net/thread-3570835-1-1.html 这里我们选择 简体 UTF8 http://down......

jayronwang
2015/09/21
151
0
服务器搭建博客或论坛所需服务器及管理软件

  服务器搭建博客或论坛   论坛:个性网技术论坛   技术从来都是有进步没有退步,如果你还在以为任何网站都需要自己敲代码完成,说明你可能落后了,本媒体只做良心平台,专门分享互联网...

人工智能未来科技
2017/11/29
0
0
宝塔Windows面板安装使用教程

  一、安装 1.系统要求:   Windows 2003 (32位)或者 Windows 2008(64位) Windows2012/2016   2.环境要求:   .NET Framework 2.0或者3.5 (注意:2012/2016需手动安装   3.安装...

人工智能未来科技
01/05
0
0
Appium入门之环境搭建

这两天试用云测试平台,发现基本都需要上传测试脚本。我不可能那么菜,于是我打算看看脚本怎么搞。这里从appium入手 阿里云MQC的文档是写的比较详细的,这里作一下推荐阿里云MQC-Appium环境搭...

notis
2017/11/14
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

游戏开发经验谈(二):对战类全球服游戏的设计与实现

上篇文章《游戏开发经验谈(一):游戏架构里隐藏的五个坑及其应对方案》,我们主要讲解了游戏架构设计当中隐藏的一些坑及其应对方案,错过的小伙伴可以回溯之前的内容。本期内容,将会重点介...

UCloudTech
10分钟前
0
0
Mysql基本语法

一.联合主键 drop table CONTENT_AND_CATALOG;CREATE TABLE `tobebetter`.`CONTENT_AND_CATALOG` ( `ID` VARCHAR(120) NOT NULL , `CONTENT_ID` VARCHAR(120) , `CA......

我是菜鸟我骄傲
12分钟前
0
0
179. centos7 安装mariadb

1. centos7 中安装mariadb 1.1 执行安装 centos7 自带了mariadb yum -y install mariadb mariadb-server 1.2 启动mariadb systemctl start mariadb 1.3 设置开机启动 systemctl enable maria......

Lucky_Me
19分钟前
0
0
【AI实战】动手训练自己的目标检测模型(YOLO篇)

在前面的文章中,已经介绍了基于SSD使用自己的数据训练目标检测模型(见文章:手把手教你训练自己的目标检测模型),本文将基于另一个目标检测模型YOLO,介绍如何使用自己的数据进行训练。 ...

雪饼
25分钟前
0
0
Git合并指定文件到另一个分支

经常被问到如何从一个分支合并特定的文件到另一个分支。 其实,只合并你需要的那些commits,不需要的commits就不合并进去了。 合并某个分支上的单个commit 首先,用git log或sourcetree工具查...

yeahlife
32分钟前
0
0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部