下载地址:https://dev.mysql.com/downloads/mysql
- 可以通过命令net start mysql启动MySQL的服务了。通过命令net stop mysql停止服务。通过命令sc delete MySQL/mysqld -remove卸载 MySQL 服务;
第一步卸载;
安装包安装:
- 解压压缩包(32位操作系统的请解压winx32的压缩包)
- 添加环境变量:
G:\Develop\mysql-8.0.12-winx64中创建配置文件
配置文件中复制下面一段进去:
[mysqld]
# Set port 3306
port=3306
# Set up mysql's installation directory
basedir=G:\\Develop\\mysql-8.0.12-winx64
# Remember here that you have to use the double slash to be in the line,
#and I'm going to make a mistake here,
#but I have a single slash in the tutorial. Try it yourself
# Set up a directory of data for the mysql database
datadir=G:\\Develop\\mysql-8.0.12-winx64\\data
# The same as above
# Maximum number of connections
max_connections=200
# Number of connections allowed to fail. This is to prevent someone from trying to
#attack the database system from the host
max_connect_errors=10
# The default character set used by the server is UTF8
character-set-server=utf8
# The default storage engine that will be used when creating a new table
default-storage-engine=INNODB
# By default“mysql_native_password”Plug-in authentication
default_authentication_plugin=mysql_native_password
[mysql]
# Set the mysql client's default character set
default-character-set=utf8
[client]
# Sets the default port used when mysql client connects to the server
port=3306
default-character-set=utf8
进入bin目录,执行以下dos命令:
①mysqld --initialize --console
2018-09-08T11:55:18.250655Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost
: >fAKX1%yy*gS
是初始密码。
②mysqld --install
③启动mysql后(通过命令net start mysql启动MySQL的服务)
在MySQL安装目录的 bin 目录下执行命令:mysql -u root -p
、重置密码即可;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
、、
可选:
创建远程登录用户:
-
管理员root的host是localhost,代表仅限localhost登录访问。如果要允许开放其他ip登录,则需要添加新的host。如果要允许所有ip访问,可以直接修改成“%”;
-
创建用户:
-
-
CREATE USER 'xxh'@'%' IDENTIFIED WITH mysql_native_password BY 'xxh123!@#';
-
grant all on *.* to root@'%'identified by 'password' 设置一个root用户允许远程登录
检查用户:
select user, host, plugin, authentication_string from user\G;
授权所有权限 :
GRANT ALL PRIVILEGES ON *.* TO 'xxh'@'%';
授权基本的查询修改权限,按需求设置:
-
-
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON *.* TO 'xxh'@'%';
查看用户权限。
show grants for 'xxh'@'%';
2019.01.24 更新
安装多个mysql ,原来安装了mysql 8 、我这里需要安装 mysql 5.7 版本、
先说下思路、
1、正常安装 mysql 5.7 ,注意配置mysql 5.7 的环境变量、
安装时候命名mysql 为 mysql2 ,防止和原来安装的mysql 冲突、
注意mysql 5.7 端口号不能是3306 ,防止冲突
2、启动服务,链接即可、
当然配置文件 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.
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
[mysqld]
#设置3306端口
port = 3307
# 设置mysql的安装目录
basedir=G:\\Develop\\mysql-5.7.17-winx64
# 设置mysql数据库的数据的存放目录
datadir=G:\\Develop\\mysql-5.7.17-winx64\\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
# 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 = .....
# datadir = .....
# port = .....
# 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