mysql install on windows

MySQL  is a relational database management system developed by the Swedish MySQL AB company. It was acquired by SUN in 2008, and later Sun was acquired by Oracle.

1. Download

MySQL  official website  https://www.mysql.com/

Click  DOWNLOADS into the download address, you will see several different versions:

  • MySQL Enterprise Edition: Enterprise Edition (charged)
  • MySQL Cluster CGE: Advanced Cluster Edition (charged)
  • MySQL Community Edition: Community Edition (open source and free, but the official does not provide technical support)

Usually we use the community version. Click to enter the community version, see a lot of things, a little stunned, don't worry, in fact, click the first  MySQL Community Server download.

So the actual download address is actually: https://dev.mysql.com/downloads/mysql/

Pull down to select the  Windows  system.

The installation version and the decompression version are provided here. The installation version is 32-bit (of course, it can also be installed under 64-bit system), and the decompression version is 64-bit.

After clicking  Download , it will jump to the following page, this is for you to register / login, ignore it, click on the lower left corner to  No thanks, just start my download. start downloading.


The installation version is 32-bit, and most of the current machines are 64-bit machines. Although 32-bit programs can also be installed, it is not recommended. The installation of the installation version is also relatively easy, so here only talk about the installation of the decompression version.

Two, unzip version configuration

1. Configure environment variables

Unzip the installation package to the directory you want to install, and add the  bin directory to the environment variable.
Add environment variables

2. Configure my.ini

Create a new my.ini file in the root directory  .
my.ini

In  my.ini add the following configuration:

[mysqld]
; Set port 3306
port = 3306
; Set mysql installation directory
basedir = D: \\ mysql-5.6.47-winx64
; Set mysql database data storage directory
datadir = D: \\ mysql-5.6.47- winx64 \\ data
; buffer directory
tmpdir = D: \\ mysql-5.6.47-winx64 \\ data
; Maximum allowed connections
max_connections = 200
; Number of allowed connection failures. This is to prevent someone from this host trying to attack the database system
max_connect_errors = 10
; the character set used by the
server is UTF8 character-set-server = utf8
by default; the default storage engine that will be used when creating new tables
default-storage-engine = INNODB
; Use the "mysql_native_password" plugin authentication by default
default_authentication_plugin = mysql_native_password
[mysql]
; Set the default character set of the mysql client
default-character-set = utf8
[client]
; Set the default port used by the mysql client to connect to the server
port = 3306
default-character-set=utf8


Note: basedir and datadir should be changed to your own directory.

trap:

default_authentication_plugin=mysql_native_password This sentence must be added, otherwise the initial password of root may not be able to log in.

3. Initialize the database

 Run  cmd as an administrator , switch to the bin  directory of the installation directory  , and enter the following command:

mysqld --initialize --console

The default service name is  mysql, you can also specify the service name

mysqld --initialize --console 服务名

Generally, you will not specify the service name, but if you need to install multiple MySQL services on your computer, you can use different names to distinguish.

After successful execution, root the initial password will be displayed  , as shown below, this password needs to be saved.
root password

If not added --consolein the command  , the  log information will not be displayed in the  cmd window. You can  find a .err file in the  data directory (the directory configured by datadir in my.ini), and you can also view the log information.

Trap 1

May report "MSVCP140.dll not found"

MSVCP140.dll not found

MSVCP140.dll  is a component file of Visual Studio C ++ 2015 Redistributable.

This problem usually occurs because Visual C ++ Redistributable for Visual Studio 2015 is not installed   . This must be installed, otherwise later services will not start.
Download address: https://www.microsoft.com/zh-CN/download/details.aspx?id=48145

If it is installed, you can repair it.

You can also download an  MSVCP140.dll , copy it  C:\Windows\System32, and run the following batch command to register the dll

@echo 开始注册
copy msvcp140.dll %windir%\system32\
regsvr32 %windir%\system32\msvcp140.dll /s
@echo msvcp140.dll注册成功
@pause

After the registration is successful, run the above MySQL command to initialize the database normally. Of course, this is not recommended.


Trap 2

After the execution is complete, carefully check the output information, there may be the following warning:

'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 

UTF 8  is currently  an alias for the character set  UTF8MB3 , and will be  replaced by UTF8MB4 in a future version  . Please consider using  UTF8MB4 for clarity.

If it appears, we just need to   replace utf8 in my.ini  file  with  UTF8MB4 .

3.2, installation services

install service:

mysqld -install

Start the service:

net start mysql

If you specified another service name in the previous step, it will be  mysql changed to the service name you specified.

Log in to the database:

mysql -u root -p

At this time, you are prompted to enter the password, which is the password that you saved in the previous article.

After successful login, the following is displayed:

Change password:
execute the following statement, you can change the password to  root .

高版本  ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
低版本 set password = password('root')

 

 

MySQL  is a relational database management system developed by the Swedish MySQL AB company. It was acquired by SUN in 2008, and later Sun was acquired by Oracle.

1. Download

MySQL  official website  https://www.mysql.com/

Click  DOWNLOADS into the download address, you will see several different versions:

  • MySQL Enterprise Edition: Enterprise Edition (charged)
  • MySQL Cluster CGE: Advanced Cluster Edition (charged)
  • MySQL Community Edition: Community Edition (open source and free, but the official does not provide technical support)

Usually we use the community version. Click to enter the community version, see a lot of things, a little stunned, don't worry, in fact, click the first  MySQL Community Server download.

So the actual download address is actually: https://dev.mysql.com/downloads/mysql/

Pull down to select the  Windows  system.

The installation version and the decompression version are provided here. The installation version is 32-bit (of course, it can also be installed under 64-bit system), and the decompression version is 64-bit.

After clicking  Download , it will jump to the following page, this is for you to register / login, ignore it, click on the lower left corner to  No thanks, just start my download. start downloading.


The installation version is 32-bit, and most of the current machines are 64-bit machines. Although 32-bit programs can also be installed, it is not recommended. The installation of the installation version is also relatively easy, so here only talk about the installation of the decompression version.

Two, unzip version configuration

1. Configure environment variables

Unzip the installation package to the directory you want to install, and add the  bin directory to the environment variable.
Add environment variables

2. Configure my.ini

Create a new my.ini file in the root directory  .
my.ini

In  my.ini add the following configuration:

[mysqld]
; Set port 3306
port = 3306
; Set mysql installation directory
basedir = D: \\ mysql-5.6.47-winx64
; Set mysql database data storage directory
datadir = D: \\ mysql-5.6.47- winx64 \\ data
; buffer directory
tmpdir = D: \\ mysql-5.6.47-winx64 \\ data
; Maximum allowed connections
max_connections = 200
; Number of allowed connection failures. This is to prevent someone from this host trying to attack the database system
max_connect_errors = 10
; the character set used by the
server is UTF8 character-set-server = utf8
by default; the default storage engine that will be used when creating new tables
default-storage-engine = INNODB
; Use the "mysql_native_password" plugin authentication by default
default_authentication_plugin = mysql_native_password
[mysql]
; Set the default character set of the mysql client
default-character-set = utf8
[client]
; Set the default port used by the mysql client to connect to the server
port = 3306
default-character-set=utf8


Note: basedir and datadir should be changed to your own directory.

trap:

default_authentication_plugin=mysql_native_password This sentence must be added, otherwise the initial password of root may not be able to log in.

3. Initialize the database

 Run  cmd as an administrator , switch to the bin  directory of the installation directory  , and enter the following command:

mysqld --initialize --console

The default service name is  mysql, you can also specify the service name

mysqld --initialize --console 服务名

Generally, you will not specify the service name, but if you need to install multiple MySQL services on your computer, you can use different names to distinguish.

After successful execution, root the initial password will be displayed  , as shown below, this password needs to be saved.
root password

If not added --consolein the command  , the  log information will not be displayed in the  cmd window. You can  find a .err file in the  data directory (the directory configured by datadir in my.ini), and you can also view the log information.

Trap 1

May report "MSVCP140.dll not found"

MSVCP140.dll not found

MSVCP140.dll  is a component file of Visual Studio C ++ 2015 Redistributable.

This problem usually occurs because Visual C ++ Redistributable for Visual Studio 2015 is not installed   . This must be installed, otherwise later services will not start.
Download address: https://www.microsoft.com/zh-CN/download/details.aspx?id=48145

If it is installed, you can repair it.

You can also download an  MSVCP140.dll , copy it  C:\Windows\System32, and run the following batch command to register the dll

@echo 开始注册
copy msvcp140.dll %windir%\system32\
regsvr32 %windir%\system32\msvcp140.dll /s
@echo msvcp140.dll注册成功
@pause

After the registration is successful, run the above MySQL command to initialize the database normally. Of course, this is not recommended.


Trap 2

After the execution is complete, carefully check the output information, there may be the following warning:

'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous. 

UTF 8  is currently  an alias for the character set  UTF8MB3 , and will be  replaced by UTF8MB4 in a future version  . Please consider using  UTF8MB4 for clarity.

If it appears, we just need to   replace utf8 in my.ini  file  with  UTF8MB4 .

3.2, installation services

install service:

mysqld -install

Start the service:

net start mysql

If you specified another service name in the previous step, it will be  mysql changed to the service name you specified.

Log in to the database:

mysql -u root -p

At this time, you are prompted to enter the password, which is the password that you saved in the previous article.

After successful login, the following is displayed:

Change password:
execute the following statement, you can change the password to  root .

高版本  ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';
低版本 set password = password('root')

 

Guess you like

Origin www.cnblogs.com/xiaojianblogs/p/12728846.html