云服务器Window Server 2012R系统安装MySQL

本人用阿里云的云服务器搭建一个网站练习,不知道在Window Server 2012R2系统下如何搭建MySQL,经过度娘终于解决,所以再次记入步骤以防下次搭建忘记。

1、在MySQL官网下载软件压缩包


2、解压完后,放到相应的硬盘中,我放的位置是E盘。然后将解压后文件夹中的my-default.ini这个配置文件复制一份并将其命名为my.ini。然后将里面的内容修改为如下

# *** 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.


  [client]


 default-character-set=utf8
 port=3306

 [mysqld]
port=3306


  character_set_server=utf8


  basedir  ="E:\MySQL\mysql-5.7.17-winx64"


  datadir  ="E:\MySQL\mysql-5.7.17-winx64/data/"


 tmpdir   ="E:\MySQL\mysql-5.7.17-winx64/data/"


  socket   ="E:\MySQL\mysql-5.7.17-winx64/data/mysql.sock"


  log-error="E:\MySQL\mysql-5.7.17-winx64/data/mysql_error.log"


  character_set_server=utf8


 #server_id = 2


  #skip-locking


 max_connections=100


  table_open_cache=256


 query_cache_size=1M


  tmp_table_size=32M


  thread_cache_size=8


  innodb_data_home_dir="E:\MySQL\mysql-5.7.17-winx64\data"


  innodb_flush_log_at_trx_commit =1


 innodb_log_buffer_size=128M


 innodb_buffer_pool_size=128M


  innodb_log_file_size=10M


 innodb_thread_concurrency=16


 innodb-autoextend-increment=1000


 join_buffer_size = 128M


  sort_buffer_size = 32M


 read_rnd_buffer_size = 32M


  max_allowed_packet = 32M


  explicit_defaults_for_timestamp=true


#sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"


  sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

3、在dos下进入MySQL的bin文件夹中进行相关命令

分别输入以下3条命令:

mysqld  -console

mysqld  --initialize

mysqld install

配置成功后mysql根目录下会生成一个data文件夹。

4、修改密码

1. 到my.ini中, 在[mysqld]下添加一行skip-grant-tables忽略授权表,再忘记root密码的时候,这是个很有用的参数. 
2. 启动MySQL, 在DOS中输入 mysql -uroot -pu就是user,p自然就是password,记得u和p与后面的用户名密码间不要有空格.这里回车后,会让你输入一个密码,随便输入一个你的密码就可以. 
3. mysql> update mysql.user set authentication_string=password('
12345') where user='root' and Host = 'localhost';括号中是自己的密码.记得结尾有个分号. 
4. mysql> flush privileges; 
5. mysql> quit; 
6. 回到配置文件中,删除skip-grant-tables这一行,保存重启mysql即可. 
7. 之后修改密码,使用mysql>SET PASSWORD = PASSWORD('123456');

配置完成后就可以通过DOS进入Mysql。

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值