如何在64位WIN7下安装64位的解压版MySQLmysql-5.6.14

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在64位WIN7下安装64位的解压版MySQLmysql-5.6.14相关的知识,希望对你有一定的参考价值。

安装mysqlmysql-5.6.14可以参考如下安装步骤:

1、将解压缩后的文件放到自己想要的地方,并配置环境变量。示例中存放的目录为:F:\mysql\mysql-5.6.14-winx64

2、在环境变量中添加:MYSQL_HOME:F:\mysql\mysql-5.6.14-winx64,在path路径中加入:%MYSQL_HOME%\bin。配置环境变量不是必须的,只是为了能更方便的在命令行中使用mysql的命令行工具。

3、修改ini配置文件

5.6.14的解压缩版里有一个my-default.ini文件,copy一份改名为my.ini放在同级目录下。修改my.ini, my.ini内容如下:

# 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]
loose-default-character-set=utf8
basedir = F:/mysql/mysql-5.6.14-winx64
datadir = F:/mysql/mysql-5.6.14-winx64/data
[client]
loose-default-character-set=utf8
[WinMySQLadmin]
Server=F:/mysql/mysql-5.6.14-winx64/bin/mysqld.exe
# 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
# 设置mysql的安装目录
# 设置mysql数据库的数据存放目录
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
character-set-server=utf8
# 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

4、安装服务

开始——所有程序——附件——命令提示符,右键以管理员身份运行。 输入命令:
C:\>f:
F:\>cd F:\mysql\mysql-5.6.14-winx64\bin
F:\mysql\mysql-5.6.14-winx64\bin>mysqld -install
Service successfully installed.

5、启动服务
F:\mysql\mysql-5.6.14-winx64\bin>cd\
F:\>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

6、配置用户
还在上面的命令窗口里面,输入命令:mysql -u root -p
回车后提示输入密码。
mysql解压缩版初次安装管理员root的密码为空,因此直接再回车一次就登入mysql数据库了。

F:\>mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.14 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
成功后
输入命令:use mysql;      /*使用mysql数据库*/
mysql> use mysql
Database changed
输入命令:select host,user,password from user;    /* 查看系统的账户信息 */
mysql> select host,user,password from user;
+-----------+------+----------+
| host | user | password |
+-----------+------+----------+
| localhost | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
+-----------+------+----------+
4 rows in set (0.00 sec)
host:代表mysql服务允许哪个IP来的请求。localhost和127.0.0.1指mysql服务所在的主机,即本地。::1是IPV6的IP地址写法,
全称为:0000:0000:0000:0000:0000:0000:0000:0001。现在都是IPV4的网络,可以不用管他。
user:指账户名称。不同的host下账户名称可以相同。
password:密码。
可以看到,默认账户里只支持本地连接,并且账户没有密码。现在的问题明确了,就是要将匿名用户删除,为root用户添加远程访问和密码,再为自己添加个人账户。指令如下:

mysql> update user set password=PASSWORD('root') where user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> grant all on *.* to root@'%' identify by 'root';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'ident
ify by 'root'' at line 1
mysql> grant all on *.* to walle@'%' identify by '123456' with grant option;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'ident
ify by '123456' with grant option' at line 1
mysql> delete from where user='';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'where
user=''' at line 1
mysql> select host,user,password from user;
+-----------+------+-------------------------------------------+
| host | user | password |
+-----------+------+-------------------------------------------+
| localhost | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 127.0.0.1 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| ::1 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| localhost | | |
+-----------+------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
参考技术A 1.从网上搜索并下载好mysql-5.7.4-m14-winx64.zip。2、解压到D:/mysql.(路径自己指定)3、在D:/mysql/mysql-5.7.4-m14-winx64下新建my.ini配置文件内容如下:####################配置文件开始####################Foradviceonhowtochangesettingspleasesee#***DONOTEDITTHISFILE.It'satemplatewhichwillbecopiedtothe#***defaultlocationduringinstall,andwillbereplacedifyou#***upgradetoanewerversionofMySQL.[client]default-character-set=utf8[mysqld]port=3306basedir="D:/mysql/mysql-5.7.4-m14-winx64/"datadir="D:/mysql/mysql-5.7.4-m14-winx64/data/"tmpdir="D:/mysql/mysql-5.7.4-m14-winx64/data/"socket="D:/mysql/mysql-5.7.4-m14-winx64/data/mysql.sock"log-error="D:/mysql/mysql-5.7.4-m14-winx64/data/mysql_error.log"#server_id=2#skip-lockingmax_connections=100table_open_cache=256query_cache_size=1Mtmp_table_size=32Mthread_cache_size=8innodb_data_home_dir="D:/mysql/mysql-5.7.4-m14-winx64/data/"innodb_flush_log_at_trx_commit=1innodb_log_buffer_size=128Minnodb_buffer_pool_size=128Minnodb_log_file_size=10Minnodb_thread_concurrency=16innodb-autoextend-increment=1000join_buffer_size=128Msort_buffer_size=32Mread_rnd_buffer_size=32Mmax_allowed_packet=32Mexplicit_defaults_for_timestamp=truesql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES####################配置文件结束###################重点是以下配置,其中datadir的目录名称必须是:D:/mysql/mysql-5.7.4-m14-winx64/data/。4、在windows系统环境变量path,加入如下内容D:/mysql/mysql-5.7.4-m14-winx64/bin;(注意加分号)5、将mysql注册为windows系统服务具体操作是在命令行中执行以下命令(需要以管理员身份运行命令行):增加服务命令:mysqldinstallMySQL--defaults-file="D:/mysql/mysql-5.7.4-m14-winx64/my.ini"移除服务命令为:mysqldremove6、第5步成功后,打开系统服务管理可以看到mysql系统服务(此处需要注意):需要在mysql服务的登陆属性里配置管理员用户登陆(不配置从服务管理里启动报1035错误,在命令行启动报启动失败)在命令行启动mysql命令为:netstartmysql关闭mysql命令为:netstopmysql7、修改root的密码为123456命令行执行:mysql–urootmysql>showdatabases;mysql>usemysql;mysql>UPDATEuserSETpassword=PASSWORD('123456')WHEREuser='root';mysql>FLUSHPRIVILEGES;mysql>QUIT8、此时可以在本机上客户端连接了(本人用的是SQLyog),有个系统库叫:mysql9、远程登陆配置允许root用户在任何地方进行远程登录,并具有所有库任何操作权限,具体操作如下:1)在本机先使用root用户登录mysql:命令行执行:mysql-uroot-p输入密码(第7步中设置的密码):1234562)进行授权操作:mysql>GRANTALLPRIVILEGESON*.*TO'root'@'%'IDENTIFIEDBY'youpassword'WITHGRANTOPTION;重载授权表:mysql>FLUSHPRIVILEGES;退出mysql:quit 参考技术B http://dev.mysql.com/downloads/mysql/5.6.html#downloads
登录到这个mysql官网下载64位zip安装包,然后安装就可以了

centos 安装多实例数据库

在Centos下安装多个MySql 5.7
① 下载MySql 解压版安装包
② 编写安装脚本
③ 将脚本和安装包放置同一目录
④ 编写my.cnf文件并放置在/etc/ 目录下
⑤ 赋予脚本运行权限并运行
⑥ 修改默认密码
① 下载MySql 解压版安装包
点击传送门:MySql下载 下载对应系统的MySql, Centos选 Linux - Generic <64位> (本人Centos是64位,32位的请选择32位)

技术图片

 

 


② 编写安装脚本

#!/bin/bash

baseMysqlDir=/usr/local/tarsPkg/mysql-5.7.22-linux-glibc2.12-x86_64

yum install mysql-devel

## 创建 MySQL 软链接
ln -s ${baseMysqlDir} /usr/local/mysql

##创建 MySQL 用户
useradd -r -s /sbin/nologin mysql

## 在 MySQL 二进制包目录中创建 mysql-files 目录
mkdir -v /usr/local/mysql/mysql-files

## 创建多实例数据目录
mkdir -vp /data/mysql_data{1..4} 

## 修改 MySQL 二进制包目录的所属用户与所属组
chown root.mysql -R ${baseMysqlDir}

## 修改 MySQL 多实例数据目录与 数据导入/导出专放目录的所属用户与所属组
chown mysql.mysql -R /usr/local/mysql/mysql-files /data/mysql_data{1..4}

## 初始化各个实例 [ 初始化完成后会自带随机密码在输出日志中 ]
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data1
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data2
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data3
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data4

## 各实例开启 SSL 连接
/usr/local/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data1
/usr/local/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data2
/usr/local/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data3
/usr/local/mysql/bin/mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql_data4

## 添加mysql 到path
echo "PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile

source /etc/profile

## 复制多实例脚本到服务管理目录下 [ /etc/init.d/ ]
cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/mysqld_multi

## 添加脚本执行权限
chmod +x /etc/init.d/mysqld_multi

## 添加进service服务管理
chkconfig --add mysqld_multi

export PATH=/usr/local/mysql/bin:$PATH

## 查个多实例状态
/etc/init.d/mysqld_multi report

 

 

③ 将脚本和安装包放置同一目录
技术图片

 

 


④ 编写my.cnf文件并放置在/etc/ 目录下

[mysqld_multi]
mysqld    = /usr/local/mysql/bin/mysqld 
mysqladmin = /usr/local/mysql/bin/mysqladmin
log        = /tmp/mysql_multi.log
[mysqld1]
federated
# 设置数据目录 [多实例中一定要不同]
datadir = /data/mysql_data1
# 设置sock存放文件名 [多实例中一定要不同]
socket = /tmp/mysql.sock1
# 设置监听开放端口 [多实例中一定要不同]
port = 3306
# 设置运行用户
user = mysql
# 关闭监控
performance_schema = off
# 设置innodb 缓存大小
innodb_buffer_pool_size = 32M
# 设置监听IP地址
bind_address = 0.0.0.0
# 关闭DNS 反向解析
skip-name-resolve = 0
max_connections=1000
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
explicit_defaults_for_timestamp=true
tmpdir=/data/mysql_data1
character_set_server = utf8mb4
[mysqld2]
datadir = /data/mysql_data2
socket = /tmp/mysql.sock2
tmpdir=/data/mysql_data2
port = 3307
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
explicit_defaults_for_timestamp=true
lower_case_table_names = 1
[mysqld3]
datadir = /data/mysql_data3
socket = /tmp/mysql.sock3
tmpdir=/data/mysql_data3
port = 3308
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 
explicit_defaults_for_timestamp=true
lower_case_table_names = 1 
[mysqld4]
datadir = /data/mysql_data4
socket = /tmp/mysql.sock4
tmpdir=/data/mysql_data4
port = 3309
user = mysql
performance_schema = off
innodb_buffer_pool_size = 32M
bind_address = 0.0.0.0
skip-name-resolve = 0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
explicit_defaults_for_timestamp=true

 

⑤ 赋予脚本运行权限并运行
技术图片

 

 


执行结果:

技术图片

 

 


⑥ 修改默认密码
技术图片

 

 


记得修改每一个默认密码哦

以上是关于如何在64位WIN7下安装64位的解压版MySQLmysql-5.6.14的主要内容,如果未能解决你的问题,请参考以下文章

在Win7 64位旗舰版下,利用Vs2008编译64位的Qt 4.8.2

转载64位Win7下成功安装64位的Oracle32位的InstantClient和PLSQL Developer

怎么安装win7 64位系统

64位win7系统如何安装MySQL

PLSQL Developer win7 64位 安装方法

MySQL5.7.25(解压版)Windows下详细的安装过程