Installing MySQL on Windows server R2

Source: Internet
Author: User
Tags documentation mysql command line

Installing with the MSI installation package

Download the corresponding 32-bit or 64-bit installation package according to your operating system. To do this, follow these steps:

MySQL Database official website of Http://dev.mysql.com/downloads/mysql,
First step: Install License
Double-click the installation file, tick "I accept the License Terms" in the interface shown, and click "Next".

Step Two: Select the setting type
As shown, there are 5 types of settings:

    • Developer Default: Install MySQL server and the tools you need to develop your MySQL application. Tools include a GUI workbench for developing and managing servers, an Excel plug-in that accesses operational data, plug-ins developed with Visual Studio integration, connectors for accessing data through NET/JAVA/C/C++/OBDC, examples and tutorials, and development documentation.
    • Serveronly: Install MySQL server only, suitable for deploying MySQL server.
    • client only: Installs clients only, and is suitable for MySQL application development based on existing MySQL server.
    • full: Install all available MySQL components.
    • Custom: Customize the components that need to be installed.

MySQL will default to the "Developer default" type, personal advice to choose the pure "Server only" type, reduce the reliance on the tool can be more in-depth learning and understanding of MySQL database. You can choose the right type according to your needs, here Select "Server only" and then click "Next".

Step three: install
Go to the installation step of the interface, if the second step to select the other type is just click "Next" to enter the step, click "Execute". As shown in the following:

After the installation is complete, click "Next" until you reach the configuration page.

Fourth Step: Configure
Go to the configuration page as shown in:

Click the content Type drop-down box to display three types:

    • DevelopmentMachine: the development of machines, MySQL will occupy the smallest amount of memory.
    • Server machine: servers, several server applications run on the machine and apply to the database server as a Web site or application, which consumes medium memory.
    • dedicatedmachine: a machine dedicated to running a MySQL database server that consumes all of the machine's available memory.

Choose the appropriate type of configuration for your own use, I'm here to do a high concurrency performance test on the back to select the "Server machine" type.

After selecting the configuration type, make a connection configuration such as:

Commonly used is TCP/IP connection, tick the box, the default port number is 3306, can be changed in the input box. If the database is only used natively, check "open Firewall port for network access" to turn on the firewall and do not tick if remote calls are required.
The following "Named Pipe" and "Shared Memory" are inter-process communication mechanisms, generally not checked.
The Show advanced options is used in the next steps to configure the premium option to learn as much as possible about the configurable items of MySQL, which is checked in this box. Click "Next" to proceed to the next step.

Fifth Step: account Configuration
Go to MySQL's account and role configuration interface, such as:

The root account has all the permissions of the database, enter the password in the password box that you set. Database in the development and maintenance process for security and ease of management will give different users the appropriate operation rights of the account password, click the "Add User" button, in the popup session box set different permission level of the account, as shown in:

Host represents the address to which the database can be connected and can be set to local (localhost/127.0.0.1), an external IP (such as 218.17.224.228), an external network segment (such as 218.17.224.*), or all hosts (%).
Roles represent the role of the account, and the following roles can be selected:

Different roles have different permission levels, can not be configured temporarily, follow-up in the User Rights Management Section detailed explanation.

Sixth Step: Configure the Windows Service
When the MySQL service is configured as a Windows service, the MySQL service automatically starts with the startup of the Windows operating system and stops as the operating system stops, which is also the recommended configuration for the MySQL official documentation, such as:

Windows Service name can be set to the default value, as long as it differs from other services by name. In a Windows system based on security requirements, the MySQL service needs to run under a given account and select the default standard System accounts. Leave the default configuration and click "Next".

Seventh Step: Advanced Configuration
Because the "Show advanced options" option is checked in the previous fourth step, a higher-level option configuration appears as shown:

Here you can configure the storage path for various log files, which are stored by default in the MySQL installation directory under the data directory, unless you must not recommend changes. Slow query log (slow query log) is followed by a seconds configuration item with a default value of 10, which means that a SQL query that has not been queried after 10s will log this query to Slow query log, allowing DBAs to quickly find inefficient operations. The Bin log can be used for master-slave data synchronization. The bottom server ID is used for the Master-slave configuration. These will be covered in the next course, where the default configuration is maintained. Click "Next".

Eighth Step: Server Configuration Application
After the above configuration, a MySQL database has been basically configured to complete. After entering this step, click "Execute" to execute the configuration items, such as:

Wait until the following screen shows the installation is successful, click "Finish" to complete.

Installing with a compressed package

Download the corresponding 32-bit or 64-bit compression package according to your operating system. To do this, follow these steps:
First step: unzip
You can also customize the path by extracting the compressed package to the C:\Program files\mysql path. My path is C:\Program files\mysql\mysql-5.7.10-winx64, such as:

Step Two: Configure environment variables
Right click on "Computer", select "Properties", open "advanced system Settings", "Environment variables", select "Path" item in system variable, and click Edit, such as:

Keep the original value unchanged and append C:\Program Files\mysql\mysql-5.7.10-winx64\bin at the end, and configure the bin directory under the MySQL installation path to the PATH variable. Enables the MySQL command to be executed under any directory on the command line.

Step Three: Modify the configuration
Open the MySQL installation directory below the My-default.ini file, locate the Basedir and DataDir property entries, remove the previous comment symbol #, and modify the values as follows:
Basedir = C:\Program files\mysql\mysql-5.7.10-winx64
DataDir = C:\Program Files\mysql\mysql-5.7.10-winx64\data
Represents MySQL's installation directory and data directory, respectively. If you unzip to a different folder in the first step, the corresponding value is modified.
Then rename the file to My.ini.

Fourth Step: Install
Run cmd as Administrator and go to the MySQL bin directory to execute the initialization command:

mysqld --initialize --user=mysql --console
    • 1
    • 1

This command is used to initialize the data, which is not required to be executed in versions prior to 5.7. A temporary root password, such as a red box, is provided when the initialization is complete and the password is noted.

Then execute the following command to install the MySQL service:

mysqld –install mysql
    • 1
    • 1

MySQL is the default service name, can not be written, if the installation is successful, the following prompt:

It is important to note that you must run CMD as an administrator, otherwise the prompt will appear as shown:

Fifth Step: start the service
In the Administrator cmd window, execute the following command to start the MySQL service:

start mysql
    • 1
    • 1

When the prompt appears as shown, the MySQL installation and startup succeeds.

MySQL5.7 Previous versions do not need to perform the mysqld–initialize command in step fourth during installation, if you omit the command, the following error occurs in this step:

Because some files and folders in this version of the package (such as the Data folder) need to be created after the Mysqld-initialize command is executed. I was in the 5.6 version of the installation process to install the here have eaten a lot of losses, I hope this as a ring, no longer step on the pit.

Sixth step: Login
Execute the following command:

-uroot -p
    • 1
    • 1

Prompt to enter a password, enter the password in the fourth step, press ENTER after the following page appears to indicate the successful login, and entered the MySQL command line mode.

Seventh Step: Change the password
Execute the following command on the MySQL command line:

ALTER USER ‘root’@’localhost’  IDENTIFIED BY ‘new_password’
    • 1
    • 1

Everyone changes to their own password, as shown in the change success:

If you execute other SQL commands without changing the password, you will be prompted with the following error:

After the above steps, the MySQL server installation is complete.

Installing MySQL on Windows server R2

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.