返回列表 发帖

最新MySQL- 8.0.17-winx64.zip安装包安装与配置详解

本帖最后由 techbridge 于 2019-8-13 13:48 编辑

最新MySQL- 8.0.17-winx64.zip安装包安装与配置
作者:逍遥客 20190813@泰科贝瑞科技(北京)有限公司 www.techbri.com

步骤一:创建MySQL安装目录(如C:\MySQL),将MySQL- 8.0.17-winx64.zip文件解压至MySQL目录下
步骤二:以管理员权限运行cmd.exe,进入MySQL\bin目录,运行mysqld install
步骤三:进入MySQL\bin目录,运行mysqld --initialize初始化MySQL,命令完成后会生成data目录
步骤四:进入data目录,用记事本打开后缀为.err的文件,找到上一步生成的root用户的临时密码
步骤五:在MySQL目录下创建配置文件my.ini(文本文件),键入以下内容:
[mysqld]
basedir=C:\MySQL\bin
datadir=C:\MySQL\data
port=3306
保存文件
步骤六:在cmd窗口运行net start mysql启动mysql服务,成功后MySQL服务启动
步骤七:在cmd窗口运行mysql -u root -p,输入步骤四中找到的root临时密码登录mysql
步骤八:在mysql>提示符下输入 set  password =’your new password’更改密码
步骤九:在mysql>提示符下输入quit退出。
至此MySQL服务配置完成。

特别提醒:步骤二可能会提醒缺msvcp140.dll,可到微软网站下载:https://www.microsoft.com/zh-cn/ ... ation.aspx?id=53587

2.3.4 Installing MySQL on Microsoft Windows Using a noinstall ZIP Archive

2.3.4.1 Extracting the Install Archive
2.3.4.2 Creating an Option File
2.3.4.3 Selecting a MySQL Server Type
2.3.4.4 Initializing the Data Directory
2.3.4.5 Starting the Server for the First Time
2.3.4.6 Starting MySQL from the Windows Command Line
2.3.4.7 Customizing the PATH for MySQL Tools
2.3.4.8 Starting MySQL as a Windows Service
2.3.4.9 Testing The MySQL Installation

Users who are installing from the noinstall package can use the instructions in this section to manually install MySQL. The process for installing MySQL from a ZIP Archive package is as follows:

    Extract the main archive to the desired install directory

    Optional: also extract the debug-test archive if you plan to execute the MySQL benchmark and test suite

    Create an option file

    Choose a MySQL server type

    Initialize MySQL

    Start the MySQL server

    Secure the default user accounts

This process is described in the sections that follow.

2.3.4.2 Creating an Option File

If you need to specify startup options when you run the server, you can indicate them on the command line or place them in an option file. For options that are used every time the server starts, you may find it most convenient to use an option file to specify your MySQL configuration. This is particularly true under the following circumstances:

    The installation or data directory locations are different from the default locations (C:\Program Files\MySQL\MySQL Server 8.0 and C:\Program Files\MySQL\MySQL Server 8.0\data).

    You need to tune the server settings, such as memory, cache, or InnoDB configuration information.

When the MySQL server starts on Windows, it looks for option files in several locations, such as the Windows directory, C:\, and the MySQL installation directory (for the full list of locations, see Section 4.2.2.2, “Using Option Files”). The Windows directory typically is named something like C:\WINDOWS. You can determine its exact location from the value of the WINDIR environment variable using the following command:

C:\> echo %WINDIR%

MySQL looks for options in each location first in the my.ini file, and then in the my.cnf file. However, to avoid confusion, it is best if you use only one file. If your PC uses a boot loader where C: is not the boot drive, your only option is to use the my.ini file. Whichever option file you use, it must be a plain text file.
Note

When using the MySQL Installer to install MySQL Server, it will create the my.ini at the default location, and the user executing MySQL Installer is granted full permissions to this new my.ini file.

In other words, be sure that the MySQL Server user has permission to read the my.ini file.

You can also make use of the example option files included with your MySQL distribution; see Section 5.1.2, “Server Configuration Defaults”.

An option file can be created and modified with any text editor, such as Notepad. For example, if MySQL is installed in E:\mysql and the data directory is in E:\mydata\data, you can create an option file containing a [mysqld] section to specify values for the basedir and datadir options:

[mysqld]
# set basedir to your installation path
basedir=E:/mysql
# set datadir to the location of your data directory
datadir=E:/mydata/data

Microsoft Windows path names are specified in option files using (forward) slashes rather than backslashes. If you do use backslashes, double them:

[mysqld]
# set basedir to your installation path
basedir=E:\\mysql
# set datadir to the location of your data directory
datadir=E:\\mydata\\data

The rules for use of backslash in option file values are given in Section 4.2.2.2, “Using Option Files”.

The ZIP archive does not include a data directory. To initialize a MySQL installation by creating the data directory and populating the tables in the mysql system database, initialize MySQL using either --initialize or --initialize-insecure. For additional information, see Section 2.10.1, “Initializing the Data Directory”.

If you would like to use a data directory in a different location, you should copy the entire contents of the data directory to the new location. For example, if you want to use E:\mydata as the data directory instead, you must do two things:

    Move the entire data directory and all of its contents from the default location (for example C:\Program Files\MySQL\MySQL Server 8.0\data) to E:\mydata.

    Use a --datadir option to specify the new data directory location each time you start the server
2.3.4.3 Selecting a MySQL Server Type

The following table shows the available servers for Windows in MySQL 8.0.
Binary         Description
mysqld         Optimized binary with named-pipe support
mysqld-debug         Like mysqld, but compiled with full debugging and automatic memory allocation checking

All of the preceding binaries are optimized for modern Intel processors, but should work on any Intel i386-class or higher processor.

Each of the servers in a distribution support the same set of storage engines. The SHOW ENGINES statement displays which engines a given server supports.

All Windows MySQL 8.0 servers have support for symbolic linking of database directories.

MySQL supports TCP/IP on all Windows platforms. MySQL servers on Windows also support named pipes, if you start the server with the named_pipe system variable enabled. It is necessary to enable this variable explicitly because some users have experienced problems with shutting down the MySQL server when named pipes were used. The default is to use TCP/IP regardless of platform because named pipes are slower than TCP/IP in many Windows configurations.
2.3.4.4 Initializing the Data Directory

If you installed MySQL using the noinstall package, no data directory is included. To initialize the data directory, use the instructions at Section 2.10.1, “Initializing the Data Directory”.
2.10.1 Initializing the Data Directory

After MySQL is installed, the data directory must be initialized, including the tables in the mysql system schema:

    For some MySQL installation methods, data directory initialization is automatic, as described in Section 2.10, “Postinstallation Setup and Testing”.

    For other installation methods, you must initialize the data directory manually. These include installation from generic binary and source distributions on Unix and Unix-like systems, and installation from a ZIP Archive package on Windows.

This section describes how to initialize the data directory manually for MySQL installation methods for which data directory initialization is not automatic. For some suggested commands that enable testing whether the server is accessible and working properly, see Section 2.10.3, “Testing the Server”.
Note

In MySQL 8.0, the default authentication plugin has changed from mysql_native_password to caching_sha2_password, and the 'root'@'localhost' administrative account uses caching_sha2_password by default. If you prefer that the root account use the previous default authentication plugin (mysql_native_password), see caching_sha2_password and the root Administrative Account.

    Data Directory Initialization Overview

    Data Directory Initialization Procedure

    Server Actions During Data Directory Initialization

    Post-Initialization root Password Assignment

Data Directory Initialization Overview

In the examples shown here, the server is intended to run under the user ID of the mysql login account. Either create the account if it does not exist (see Create a mysql User and Group), or substitute the name of a different existing login account that you plan to use for running the server.

    Change location to the top-level directory of your MySQL installation, which is typically /usr/local/mysql (adjust the path name for your system as necessary):

    cd /usr/local/mysql

Within the directory you will find several files and subdirectories, including the bin subdirectory that contains the server as well as client and utility programs.

The secure_file_priv system variable limits import and export operations to a specific directory. Create a directory whose location can be specified as the value of that variable:

mkdir mysql-files

Grant directory user and group ownership to the mysql user and mysql group, and set the directory permissions appropriately:

chown mysql:mysql mysql-files
chmod 750 mysql-files

Use the server to initialize the data directory, including the mysql schema containing the initial MySQL grant tables that determine how users are permitted to connect to the server. For example:

bin/mysqld --initialize --user=mysql

For important information about the command, especially regarding command options you might use, see Data Directory Initialization Procedure. For details about how the server performs initialization, see Server Actions During Data Directory Initialization.

Typically, data directory initialization need be done only after you first install MySQL. (For upgrades to an existing installation, perform the upgrade procedure instead; see Section 2.11, “Upgrading MySQL”.) However, the command that initializes the data directory does not overwrite any existing mysql schema tables, so it is safe to run in any circumstances.

If you want to deploy the server with automatic support for secure connections, use the mysql_ssl_rsa_setup utility to create default SSL and RSA files:

bin/mysql_ssl_rsa_setup

    For more information, see Section 4.4.3, “mysql_ssl_rsa_setup — Create SSL/RSA Files”.

    In the absence of any option files, the server starts with its default settings. (See Section 5.1.2, “Server Configuration Defaults”.) To explicitly specify options that the MySQL server should use at startup, put them in an option file such as /etc/my.cnf or /etc/mysql/my.cnf. (See Section 4.2.2.2, “Using Option Files”.) For example, you can use an option file to set the secure_file_priv system variable.

    To arrange for MySQL to start without manual intervention at system boot time, see Section 2.10.5, “Starting and Stopping MySQL Automatically”.

    Data directory initialization creates time zone tables in the mysql schema but does not populate them. To do so, use the instructions in Section 5.1.13, “MySQL Server Time Zone Support”.

Data Directory Initialization Procedure

Change location to the top-level directory of your MySQL installation, which is typically /usr/local/mysql (adjust the path name for your system as necessary):

cd /usr/local/mysql

To initialize the data directory, invoke mysqld with the --initialize or --initialize-insecure option, depending on whether you want the server to generate a random initial password for the 'root'@'localhost' account, or to create that account with no password:

    Use --initialize for “secure by default” installation (that is, including generation of a random initial root password). In this case, the password is marked as expired and you will need to choose a new one.

    With --initialize-insecure, no root password is generated. This is insecure; it is assumed that you will assign a password to the account in timely fashion before putting the server into production use.

For instructions on assigning a new 'root'@'localhost' password, see Post-Initialization root Password Assignment.
Note

The server writes any messages (including any initial password) to its standard error output. This may be redirected to the error log, so look there if you do not see the messages on your screen. For information about the error log, including where it is located, see Section 5.4.2, “The Error Log”.

On Windows, use the --console option to direct messages to the console.

On Unix and Unix-like systems, it is important for the database directories and files to be owned by the mysql login account so that the server has read and write access to them when you run it later. To ensure this, start mysqld from the system root account and include the --user option as shown here:

bin/mysqld --initialize --user=mysql
bin/mysqld --initialize-insecure --user=mysql

Alternatively, execute mysqld while logged in as mysql, in which case you can omit the --user option from the command.

On Windows, use one of these commands:

bin\mysqld --initialize --console
bin\mysqld --initialize-insecure --console

Note

Data directory initialization might fail if required system libraries are missing. For example, you might see an error like this:

bin/mysqld: error while loading shared libraries:
libnuma.so.1: cannot open shared object file:
No such file or directory

If this happens, you must install the missing libraries manually or with your system's package manager. Then retry the data directory initialization command.

It might be necessary to specify other options such as --basedir or --datadir if mysqld cannot identify the correct locations for the installation directory or data directory. For example (enter the command on a single line):

bin/mysqld --initialize --user=mysql
  --basedir=/opt/mysql/mysql
  --datadir=/opt/mysql/mysql/data

Alternatively, put the relevant option settings in an option file and pass the name of that file to mysqld. For Unix and Unix-like systems, suppose that the option file name is /opt/mysql/mysql/etc/my.cnf. Put these lines in the file:

[mysqld]
basedir=/opt/mysql/mysql
datadir=/opt/mysql/mysql/data

Then invoke mysqld as follows (enter the command on a single line with the --defaults-file option first):

bin/mysqld --defaults-file=/opt/mysql/mysql/etc/my.cnf
  --initialize --user=mysql

On Windows, suppose that C:\my.ini contains these lines:

[mysqld]
basedir=C:\\Program Files\\MySQL\\MySQL Server 8.0
datadir=D:\\MySQLdata

Then invoke mysqld as follows (enter the command on a single line with the --defaults-file option first):

bin\mysqld --defaults-file=C:\my.ini
   --initialize --console

Server Actions During Data Directory Initialization
Note

The data directory initialization sequence performed by the server does not substitute for the actions performed by mysql_secure_installation and mysql_ssl_rsa_setup. See Section 4.4.2, “mysql_secure_installation — Improve MySQL Installation Security”, and Section 4.4.3, “mysql_ssl_rsa_setup — Create SSL/RSA Files”.

When invoked with the --initialize or --initialize-insecure option, mysqld performs the following actions during the data directory initialization sequence:

    The server checks for the existence of the data directory as follows:

        If no data directory exists, the server creates it.

        If the data directory exists but is not empty (that is, it contains files or subdirectories), the server exits after producing an error message:

        [ERROR] --initialize specified but the data directory exists. Aborting.

    In this case, remove or rename the data directory and try again.

    An existing data directory is permitted to be nonempty if every entry has a name that begins with a period (.).

Within the data directory, the server creates the mysql system schema and its tables, including the data dictionary tables, grant tables, time zone tables, and server-side help tables. See Section 5.3, “The mysql System Schema”.

The server initializes the system tablespace and related data structures needed to manage InnoDB tables.
Note

After mysqld sets up the InnoDB system tablespace, certain changes to tablespace characteristics require setting up a whole new instance. Qualifying changes include the file name of the first file in the system tablespace and the number of undo logs. If you do not want to use the default values, make sure that the settings for the innodb_data_file_path and innodb_log_file_size configuration parameters are in place in the MySQL configuration file before running mysqld. Also make sure to specify as necessary other parameters that affect the creation and location of InnoDB files, such as innodb_data_home_dir and innodb_log_group_home_dir.

If those options are in your configuration file but that file is not in a location that MySQL reads by default, specify the file location using the --defaults-extra-file option when you run mysqld.

The server creates a 'root'@'localhost' superuser account and other reserved accounts (see Section 6.2.9, “Reserved Accounts”). Some reserved accounts are locked and cannot be used by clients, but 'root'@'localhost' is intended for administrative use and you should assign it a password.

Server actions with respect to a password for the 'root'@'localhost' account depend on how you invoke it:

    With --initialize but not --initialize-insecure, the server generates a random password, marks it as expired, and writes a message displaying the password:

    [Warning] A temporary password is generated for root@localhost:
    iTag*AfrH5ej

With --initialize-insecure, (either with or without --initialize because --initialize-insecure implies --initialize), the server does not generate a password or mark it expired, and writes a warning message:

[Warning] root@localhost is created with an empty password ! Please
consider switching off the --initialize-insecure option.

    For instructions on assigning a new 'root'@'localhost' password, see Post-Initialization root Password Assignment.

    The server populates the server-side help tables used for the HELP statement (see Section 13.8.3, “HELP Syntax”). The server does not populate the time zone tables. To do so manually, see Section 5.1.13, “MySQL Server Time Zone Support”.

    If the init_file system variable was given to name a file of SQL statements, the server executes the statements in the file. This option enables you to perform custom bootstrapping sequences.

    When the server operates in bootstrap mode, some functionality is unavailable that limits the statements permitted in the file. These include statements that relate to account management (such as CREATE USER or GRANT), replication, and global transaction identifiers.

    The server exits.

Post-Initialization root Password Assignment

After you initialize the data directory by starting the server with --initialize or --initialize-insecure, start the server normally (that is, without either of those options) and assign the 'root'@'localhost' account a new password:

    Start the server. For instructions, see Section 2.10.2, “Starting the Server”.

    Connect to the server:

        If you used --initialize but not --initialize-insecure to initialize the data directory, connect to the server as root:

        mysql -u root -p

Then, at the password prompt, enter the random password that the server generated during the initialization sequence:

Enter password: (enter the random root password here)

Look in the server error log if you do not know this password.

If you used --initialize-insecure to initialize the data directory, connect to the server as root without a password:

mysql -u root --skip-password

After connecting, use an ALTER USER statement to assign a new root password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root-password';

See also Section 2.10.4, “Securing the Initial MySQL Account”.
Note

Attempts to connect to the host 127.0.0.1 normally resolve to the localhost account. However, this fails if the server is run with the --skip-name-resolve option. If you plan to do that, make sure that an account exists that can accept a connection. For example, to be able to connect as root using --host=127.0.0.1 or --host=::1, create these accounts:

CREATE USER 'root'@'127.0.0.1' IDENTIFIED BY 'root-password';
CREATE USER 'root'@'::1' IDENTIFIED BY 'root-password';

It is possible to put those statements in a file to be executed using the init_file system variable, as discussed in Server Actions During Data Directory Initialization.

TOP

返回列表

精品播报 关闭


物联网人才培养雾里看花 面临三无现实

去年10月由新华社发布的《2009-2010中国物联网年度发展报告》中称,2009年中国物联网产业市场规模达1716亿元;到2015年,中国物联网整体市场规模将达到7500亿元,年 ...


查看