MySQL 5.7.22 免安装配置

转自https://blog.csdn.net/hellboy0621/article/details/80458892

1、官网下载对应版本,下载地址为https://dev.mysql.com/downloads/mysql/5.7.html#downloads,我下载的文件为“mysql-5.7.22-winx64.zip”;

2、考虑到数据库容量会增加,建议解压缩到可用容量较大的盘符,我解压缩到D盘;

3、进入解压缩目录,新建my.ini文件,内容如下:

  1. [mysqld]

  2.  

    # set basedir to your installation path

  3.  

    basedir=D:/mysql-5.7.22-winx64

  4.  

    # set datadir to the location of your data directory

  5.  

    datadir=D:/mysql-5.7.22-winx64/data

4、使用cmd进入解压缩目录下的bin/目录下

  1. # 安装mysql服务,安装完成后,可在右键“计算机”-“管理”-“服务”中看到,默认服务名为“MySQL”,也可以在install后面指定服务名称

  2.  

    D:\mysql-5.7.22-winx64\bin>mysqld install

  3.  

    Service successfully installed.

  1. # 初始化data目录

  2.  

    D:\mysql-5.7.22-winx64\bin>mysqld.exe --initialize

初始化后会在datadir路径下生成一个*.err的文件,打开如下:

  1. 2018-05-27T04:49:08.182952Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

  2.  

    2018-05-27T04:49:11.016957Z 0 [Warning] InnoDB: New log files created, LSN=45790

  3.  

    2018-05-27T04:49:11.546958Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

  4.  

    2018-05-27T04:49:11.676958Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4c70979b-6169-11e8-9db4-00ff13a6d817.

  5.  

    2018-05-27T04:49:11.676958Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.

  6.  

    2018-05-27T04:49:11.696958Z 1 [Note] A temporary password is generated for [email protected]: q&10*I#<fi-w

最后一行“A temporary password is generated for [email protected]: q&10*I#<fi-w”冒号后面的就是临时密码;

  1. # 启动MySQL服务

  2.  

    D:\mysql-5.7.22-winx64\bin>net start mysql

  3.  

    MySQL 服务正在启动 .

  4.  

    MySQL 服务已经启动成功。

5、修改密码

后面有两种方式可以修改密码,一种是使用刚才生成的临时密码登录修改,另一种是修改配置文件跳过密码登录然后修改密码;

5.1 通过临时密码登录

  1. # 使用临时密码登录

  2.  

    E:\mysql-5.7.22-winx64\bin>mysql -u root -p

  3.  

    Enter password: ************

  4.  

    Welcome to the MySQL monitor. Commands end with ; or \g.

  5.  

    Your MySQL connection id is 4

  6.  

    Server version: 5.7.22

  7.  

  8.  

    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

  9.  

  10.  

    Oracle is a registered trademark of Oracle Corporation and/or its

  11.  

    affiliates. Other names may be trademarks of their respective

  12.  

    owners.

  13.  

  14.  

    Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

  15.  

  16.  

    # 查看端口号

  17.  

    mysql> show global variables like ‘port‘;

  18.  

    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

  19.  

    # 通过ALTER语句修改密码

  20.  

    mysql> ALTER user ‘root‘@‘localhost‘ identified by ‘Jiubugaosuni_01‘;

  21.  

    Query OK, 0 rows affected (0.00 sec)

  22.  

  23.  

    mysql> SHOW GLOBAL VARIABLES LIKE ‘port‘;

  24.  

    +---------------+-------+

  25.  

    | Variable_name | Value |

  26.  

    +---------------+-------+

  27.  

    | port | 3306 |

  28.  

    +---------------+-------+

  29.  

    1 row in set, 1 warning (0.01 sec)

5.2 跳过密码登录

5.2.1 跳过密码登录MySQL

  1. # 停止MySQL服务

  2.  

    D:\mysql-5.7.22-winx64\bin>net stop mysql

  3.  

    MySQL 服务正在停止.

  4.  

    MySQL 服务已成功停止。

  5.  

  6.  

    # 卸载MySQL服务

  7.  

    D:\mysql-5.7.22-winx64\bin>mysqld remove

  8.  

    Service successfully removed.

  1. # 编辑my.ini配置文件,在[mysqld]下添加skip-grant-tables

  2.  

    [mysqld]

  3.  

    # set basedir to your installation path

  4.  

    basedir=D:/mysql-5.7.22-winx64

  5.  

    # set datadir to the location of your data directory

  6.  

    datadir=D:/mysql-5.7.22-winx64/data

  7.  

    skip-grant-tables

  1. # 安装MySQL服务

  2.  

    D:\mysql-5.7.22-winx64\bin>mysqld install

  3.  

    Service successfully installed.

  4.  

  5.  

    # 启动MySQL服务

  6.  

    D:\mysql-5.7.22-winx64\bin>net start mysql

  7.  

    MySQL 服务正在启动 .

  8.  

    MySQL 服务已经启动成功。

5.2.2 无密码登录

  1. D:\mysql-5.7.22-winx64\bin>mysql -u root -p

  2.  

    Enter password:(回车,无需输入密码)

  3.  

    Welcome to the MySQL monitor. Commands end with ; or \g.

  4.  

    Your MySQL connection id is 2

  5.  

    Server version: 5.7.22 MySQL Community Server (GPL)

  6.  

  7.  

    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

  8.  

  9.  

    Oracle is a registered trademark of Oracle Corporation and/or its

  10.  

    affiliates. Other names may be trademarks of their respective

  11.  

    owners.

  12.  

  13.  

    Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

  14.  

  15.  

    mysql>

  1. # 在这里不能使用ALTER语句,否则报错

  2.  

    mysql> ALTER user ‘root‘@‘localhost‘ identified by ‘Jiubugaosuni_01‘;

  3.  

    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this

  4.  

    statement

  1. # 而应该使用如下命令,设置临时密码

  2.  

    mysql> use mysql;

  3.  

    Database changed

  4.  

    mysql> UPDATE user SET authentication_string = password("Jiubugaosuni_01") WHERE user = "root";

  5.  

    Query OK, 1 row affected, 1 warning (0.07 sec)

  6.  

    Rows matched: 1 Changed: 1 Warnings: 1

  7.  

  8.  

    mysql> FLUSH PRIVILEGES;

  9.  

    Query OK, 0 rows affected (0.00 sec)

  10.  

  11.  

    mysql> QUIT;

  12.  

    Bye

5.2.3 恢复密码登录

  1. # 停止MySQL服务

  2.  

    D:\mysql-5.7.22-winx64\bin>net stop mysql

  3.  

    MySQL 服务正在停止.

  4.  

    MySQL 服务已成功停止。

  5.  

  6.  

    # 卸载MySQL服务

  7.  

    D:\mysql-5.7.22-winx64\bin>mysqld remove

  8.  

    Service successfully removed.

  1. # 修改my.ini配置文件,注释或者删除skip-grant-tables

  2.  

    [mysqld]

  3.  

    # set basedir to your installation path

  4.  

    basedir=D:/mysql-5.7.22-winx64

  5.  

    # set datadir to the location of your data directory

  6.  

    datadir=D:/mysql-5.7.22-winx64/data

  7.  

    # skip-grant-tables

  1. # 安装MySQL服务

  2.  

    D:\mysql-5.7.22-winx64\bin>mysqld install

  3.  

    Service successfully installed.

  4.  

  5.  

    # 启动MySQL服务

  6.  

    D:\mysql-5.7.22-winx64\bin>net start mysql

  7.  

    MySQL 服务正在启动 .

  8.  

    MySQL 服务已经启动成功。

5.2.4 登录并查看端口号

  1. # 使用修改的临时密码登录

  2.  

    D:\mysql-5.7.22-winx64\bin>mysql -u root -p

  3.  

    Enter password: ***************

  4.  

    Welcome to the MySQL monitor. Commands end with ; or \g.

  5.  

    Your MySQL connection id is 3

  6.  

    Server version: 5.7.22

  7.  

  8.  

    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

  9.  

  10.  

    Oracle is a registered trademark of Oracle Corporation and/or its

  11.  

    affiliates. Other names may be trademarks of their respective

  12.  

    owners.

  13.  

  14.  

    Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

  15.  

  16.  

    # 必须通过ALTER语句修改密码才算正式修改密码成功

  17.  

    mysql> show global variables like ‘port‘;

  18.  

    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

  19.  

    mysql> ALTER user ‘root‘@‘localhost‘ identified by ‘Jiubugaosuni_01‘;

  20.  

    Query OK, 0 rows affected (0.00 sec)

  21.  

  22.  

    mysql> SHOW GLOBAL VARIABLES LIKE ‘port‘;

  23.  

    +---------------+-------+

  24.  

    | Variable_name | Value |

  25.  

    +---------------+-------+

  26.  

    | port | 3306 |

  27.  

    +---------------+-------+

  28.  

    1 row in set, 1 warning (0.04 sec)

  29.  

  30.  

    mysql> show databases;

  31.  

    +--------------------+

  32.  

    | Database |

  33.  

    +--------------------+

  34.  

    | information_schema |

  35.  

    | mysql |

  36.  

    | performance_schema |

  37.  

    | sys |

  38.  

    +--------------------+

  39.  

    4 rows in set (0.00 sec)

  40.  

  41.  

    mysql>

6、配置远程登录

  1. # 赋予全部权限在所有数据库和所有表上给root用户在任何主机上使用Jiubugaosuni_01这个密码登录  

  2.  

    mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘Jiubugaosuni_01‘ WITH GRANT OPTION;

  3.  

    Query OK, 0 rows affected, 1 warning (0.00 sec)

  4.  

  5.  

    mysql> FLUSH PRIVILEGES;

  6.  

    Query OK, 0 rows affected (0.02 sec)

原文地址:https://www.cnblogs.com/Gru-blog/p/9307981.html

时间: 2024-11-05 19:41:04

MySQL 5.7.22 免安装配置的相关文章

MySQL 5.7.9 免安装配置

MySQL 5.7.9 免安装配置 环境:win10 64位 mysql版本:mysql-5.7.9-winx64.zip (http://dev.mysql.com/downloads/mysql/) 首先声明一下,5.7.9这个版本的配置方式跟之前的免安装版配置不一样.(.msi安装版和其他版本的可以忽略该方法) 步骤: 1,在官网上下载了mysql-5.7.9-winx64.zip 这个文件之后, 解压到指定目录:F:\java\mysql\mysql-5.7.9-winx64 2,在F:

MySQL 5.7.10 免安装配置

# 配置环境:windows 64bit # 安装版本:mysql-5.7.10-win32(zip archive版本) 1. ZIP Archive版是免安装的,只需把mysql-5.7.10-win32.zip解压到安装目录即可. 2. 在D:\Program Files\mysql-5.7.10-win32文件夹下新建配置默认文件my.ini,在此文件中需要配置字符编码.该文件会替换文件夹下面的my-default.ini文件(.ini文件是windows里面的配置文件,保存里面各种默认

mysql 5.7.14 免安装配置方法教程

仅供参考 一.下载 1. 进入mysql官网,下载Mysql-5.7.14,下载地址:http://dev.mysql.com/downloads/mysql/ 2.将下载好的文件解压到自定义目录 二.配置文件 1.首先配置环境变量path,具体不再描述 2.在解压路径下复制my-default.ini,修改名称为my.ini # basedir = E:\mysql (此处为mysql文件路径,自定义)# datadir = E:\mysql\data (此处为mysql文件路径,自定义)#

mysql 免安装 配置及远程访问

1.将下载的MySQL压缩包解压到自定义目录下(D:\Program Files (x86)\mysql-5.6.16-winx64). 2.将mysql注册为windows系统服务 操作如下: 1)新建一个my.ini文件并把my.ini文件放到D:\Program Files (x86)\mysql-5.6.16-winx64\下,my.ini内容如下: [client] port=3306 default-character-set=utf8 [mysqld] # 设置为MYSQL的安装目

MySQL 5.7.22 二进制安装

MySQL 5.7.22 二进制安装 一.到官网下载mysql-5.7.22二进制包 二.创建mysql用户: useradd mysql -s /sbin/nologin -M 三.解压mysql-5.7.22-el7-x86_64.tar.gz : tar xf mysql-5.7.22-el7-x86_64.tar.gz && mv mysql-5.7.22-el7-x86_64.tar.gz /opt/mysql 四.创建相关目录: cd /opt/mysql mkdir {dat

Tomcat的免安装配置

Tomcat免安装配置 以下配置说明全部针对免安装版本 基于tomcat的安装目录和运行目录是可以不同的,本文都会进行说明 首先简单介绍一下tomcat的目录结构,一般情况下,tomcat包括以下子目录: bin.conf.lib.logs.temp.webapps.work 按作用不同,主要分为两大类: 安装目录(Home):bin和lib 运行目录(Base):conf.temp.webapps(logs和work会在启动后自动生成) Home目录只需要一个,Base目录可配置任意个,且独立

Keepalived+Mysql互为主从高可用安装配置

Keepalived+Mysql互为主从高可用安装配置环境介绍:keepalived_vip=192.168.1.210    (写虚拟ip)mysql_master01      eth0:192.168.1.211  eth1:172.20.27.211 (1核1G)mysql_master02      eth0:192.168.1.212  eth1:172.20.27.212 (1核1G) 1.安装mysql数据库(所有节点安装)  //此处省略安装mysql服务2.编辑my.cnf配

mysql物理备份工具Xtrabackup安装配置

mysql物理备份工具Xtrabackup安装配置 1????Xtrabackup工具介绍 Xtrabackup是一个对InnoDB做物理数据备份的工具,支持在线热备份(备份时不影响数据读写),是商业备份工具InnoDB Hotbackup的一个很好的替代品. Xtrabackup有两个主要的工具:xtrabackup.innobackupex (1)xtrabackup只能备份InnoDB和XtraDB两种数据表,而不能备份MyISAM数据表. (2)innobackupex是用来备份非Inn

mysql免安装配置

准备 在mysq官网 http://dev.mysql.com/downloads/mysql/,下载最新稳定版本 版本简介参考:1. MySQL Community Server 社区版本,开源免费,但不提供官方技术支持.2. MySQL Enterprise Edition 企业版本,需付费,可以试用30天.3. MySQL Cluster 集群版,开源免费.可将几个MySQL Server封装成一个Server.4. MySQL Cluster CGE 高级集群版,需付费.作为开发者使用,