Install and use MYSQL on windows

Installation method using ZIP compressed package

1. Introduction of some MYSQL related programs provided by https://dev.mysql.com/downloads/. **

MySQL Community Server
MySQL service program
MySQL Cluster
MySQL Cluster is a highly practical and highly redundant version of MySQL suitable for distributed computing environments. It uses the NDB Cluster storage engine, which allows multiple MySQL servers to run in a cluster.
MySQL Cluster is a technology that allows the deployment of "in-memory" database clusters in shared-nothing systems. With a shared-nothing architecture, the system can use inexpensive hardware and has no special requirements for hardware and software. In addition, since each component has its own memory and disk, there is no single point of failure.
MySQL Cluster is composed of a group of computers, each of which runs a variety of processes, including MySQL server, NDB Cluster data node, management server, and (possibly) special data access program. For the relationship between these components in Cluster, please refer to the following figure:
Insert picture description here
MySQL Router
MySQL Router is a lightweight MySQL middleware officially provided by MySQL, which is used to replace the previous old version of SQL proxy.

Since MySQL Router is a database middleware, MySQL Router must be able to analyze whether the SQL request from the previous client is a write request or a read request, in order to determine whether this SQL request is sent to the master or slave, and which master and which slave to send. In this way, MySQL Router implements MySQL read-write separation and load balances MySQL requests.

Therefore, the premise of MySQL Router is that the back-end implements master-slave replication of MySQL.
A simple MySQL Router deployment diagram is as follows
Insert picture description hereMySQL Shell
mysql-shell is an advanced mysql command-line tool, it directly two modes (interactive & batch) three languages ​​(javascript \ python \ sql)

If you still have some doubts about this tool, the latest version of InnoDB Cluster can be used as one of the standard components. If you want to build this environment, the standard steps inside are based on the operation of MySQL Shell, plus MySQL Router, MGR, this set is complete.
Insert picture description hereMySQL Workbench
Workbench is a graphical management tool for MySQL. It is much more convenient than the MySQL Command line client, and its practicality is also very high.
MySQL Notifier
MySQL Notifier is one of the DBA tools officially supported by MySQL. MySQL Notifier is an auxiliary tool for MySQL database. It can reside icons in the notification area (system tray) of the system taskbar for quick monitoring and changing the status of server instances (services). At the same time, it can also be integrated with some graphical management tools (such as MySQL Workbench).
Connector / ODBC
This is MySQL's ODBC driver
ODBC (Open Database Connectivity), open database interconnection. It provides a unified interface for writing client software for relational databases. ODBC provides a standard API that can be used to handle customer applications in different databases. Applications that use the ODBC API can communicate with any relational database with ODBC drivers. ODBC is a standard interface for client applications to access relational databases. For different databases, ODBC provides a unified API. Use this API to access any database that provides ODBC drivers. The relationship between the client program, ODBC interface, database driver and database is as follows:
Insert picture description here

2. Install MySQL on Windows

Note: Just started to run mysql.exe under bin /, suggesting that vcruntime140.dll is missing, you need to install Visual C ++ Redistributable for Visual Studio 2015. mysql.exe is to start the MySQL service (it seems that administrator rights are required to start), the following operations are required to install the MySQL service

Configure MySQL configuration file
After downloading, we will unzip the zip package to the corresponding directory, here I will put the unzipped folder under C: \ web to
open the folder just unzipped C: \ web \ mysql-8.0.11 , There is a configuration file my-default.ini that comes with the system, copy the file and paste it in the bin directory, set the new file to my.ini, edit my.ini to configure the following basic information (if you can not find the above This file, directly create a new my.ini file, write the following content):

  [mysql]
  #设置mysql客户端默认字符集
  default-character-set=utf8
  [mysqld]
  #设置3306端口  (系统默认会给其分配3306端口)
 port = 3306
 #设置mysql的安装目录
 basedir=C:\web
  #设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配  置,系统自己生成即可,否则有可能报错
  # datadir=C:\\web\\sqldata
  # 允许最大连接数
  max_connections=20
  # 服务端使用的字符集默认为8比特编码的latin1字符集
  character-set-server=utf8
  # 创建新表时将使用的默认存储引擎
  default-storage-engine=INNODB

Start the MySQL database:
Open the cmd command-line tool as an administrator and change the directory:
cd C: \ web \ mysql-8.0.11 \ bin
Initialize the database:
mysqld --initialize --console After the
execution is completed, the initial output of the root user will be output Default password
Enter the following installation command:
mysqld install
Start the following command:
net start mysql
modify the password
mysqladmin -u USER -p password PASSWORD (Note: This command is in the C: \ web \ mysql-8.0.11 \ bin directory (Executed)
When the installation is wrong and needs to be reinstalled, use the command to remove the installed mysql: mysqld --remove mysql
Note: The installation path of mysql must not have Chinese, otherwise it will report "MySQL service cannot be started. The service did not report any errors" mistake. Of course, there are other reasons for this error, such as you have not initialized the data directory or the port is occupied

Note: The data directory needs to be initialized in 5.7:
cd C: \ web \ mysql-8.0.11 \ bin mysqld --initialize-insecure After
initialization, run net start mysql to start mysql.

Log in to MySQL
When the MySQL service is already running, we can log in to the MySQL database through the client tool that comes with MySQL. First, open a command prompt and enter the command in the following format:
mysql -h hostname -u username -p
if we To log in to the local MySQL database, just enter the following command:
mysql -u root -p
Press Enter to confirm, if the installation is correct and MySQL is running, you will get the following response:
Enter password:
If the password exists, enter the password to log in , If it does not exist, just press Enter to log in.

Note: When you log in to the database with the initial password, the error "ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement" appears during the execution of the command. You need to change your own password, through the following statement, mysql> ALTER USER USER () IDENTIFIED BY 'password';

3. Install MySQL ODBC

Note: Just started running myodbc-installer.exe in the bin \ directory, the system prompts that vcruntime140_1.dll is missing, copy the dynamic link library vcruntime140_1.dll on the system with vcruntime140_1.dll, and paste it into the system C: \ Windows \ System32 In the directory, or download vcruntime140_1.dll, and then put it in the C: \ Windows \ System32 directory, so myodbc-installer.exe can run, but there is no MySQL ODBC driver in the ODBC data source manager after running. The following operations are required to install the MySQL ODBC driver.

Configuration environment
Unzip the downloaded zip package, enter the lib directory under the decompressed folder directory, copy the following files to your personal needs, you can copy according to the officially recommended address (C: \ Windows \ System32):
lib \ myodbc8S.dll-> c: \ Windows \ System32
lib \ myodbc8S.lib-> c: \ Windows \ System32
choose to install the corresponding Driver:
Unicode-enabled driver:
lib \ myodbc8w.dll-> c: \ Windows \ System32
lib \ myodbc8w.lib-> c: \ Windows \ System32
ANSI driver:
lib \ myodbc8a.dll-> c: \ Windows \ System32
lib \ myodbc8a.lib-> c: \ Windows \ System32

Configure environment variables:
Select the "this computer" icon on the desktop, right-click-> Properties-> click "Advanced System Settings"-> click "Environment Variables".
Edit Path system variables directly here. Click the "New" button and add: G: \ MySQL_odbc \ mysql-connector-odbc-noinstall-8.0.16-winx64 \ bin (write according to the path of your system's bin / directory).

Install the driver and
open the command indicator with the administrator, enter the G: \ MySQL_odbc \ mysql-connector-odbc-noinstall-8.0.16-winx64 \ folder directory (write according to the directory path of the folder you unzipped), enter " Install.bat ", click Enter to run.
Install with Install.bat is to install two drivers directly, if you only want to install one driver, you can use the following command:
Unicode-enabled driver:
myodbc-installer.exe -d -a -n "MySQL ODBC 8.0 Unicode Driver"- t “DRIVER = myodbc8w.dll; SETUP = myodbc8S.dll”
ANSI driver:
myodbc-installer -d -a -n “MySQL ODBC 8.0 Driver” -t "DRIVER = myodbc8a.dll; SETUP = myodbc8S.dll"

If Success: Usage count is 1, the installation is successful. To see if the installation is successful, go to the management tools under the control panel.
Find the ODBC data source, in the ODBC management that appears, click to create a new ODBC, if the MySQL ODBC driver appears, it means that it can be used.

4. Use Workbench to operate the database

In MySQL, SCHEMAS is equivalent to a list of DATABASES. Right-click in the blank space of the SCHEMAS list and select Refresh All to refresh the current database list.
Insert picture description here Create a database
Right-click in the blank space of the SCHEMAS list and select "Create Schema ..." to create a database.
In the dialog box for creating a database, enter the name of the database in the Name box and select the character set specified by the database in the Collation drop-down list. Click the Apply button to create successfully.
After setting in the dialog box of creating database, you can preview the SQL script of the current operation, that is, CREATE DATABASE test_db, then click the Apply button, and finally click the Finish button in the next pop-up dialog box to complete the database test_db create.
Modify the database
After the database is successfully created, you can modify the character set of the database. Right-click on the database that needs to modify the character set and select the "Alter Schema ..." option to modify the character set specified by the database.
In the Modify Database dialog box, the name of the database cannot be modified. In the Collation drop-down list, select the character set to which the database needs to be modified. Click the Apply button to create successfully.
Deleting a database
You can delete a database in the SCHEMAS list, right-click on the database to be deleted, and select "Drop Schema ...".
Click the Drop Now button in the pop-up dialog box to delete the database directly.
If you click the Review SQL button, the SQL statement corresponding to the delete operation can be displayed. Click the Execute button to execute the delete operation.
Set the default database
In the SCHEMAS list, you can select the default database, right-click on the database that needs to specify the default, and select Set As Default Schema. This operation is equivalent to the USE <database_name> command in the command line tool.

5. Use Workbench to manipulate the data sheet

Create a data table
Open the MySQL Workbench software, expand the current database you want to create a data table in the SCHEMAS list, right-click on the Tables menu, select "Create Table ...", you can create a data table in the database.
In the dialog box for creating a data table, enter the name of the data table in the Table Name box. Edit the column information of the data table in the middle part of the dialog box. After editing, click the Apply button to successfully create the data table.
After the setting is completed, you can preview the SQL script of the current operation, then click the Apply button, and finally click the Finish button in the next pop-up dialog box to complete the creation of the data table.

Insert picture description here

View the data table
After the data table is successfully created, you can view the structure information of the data table. Right-click on the data table that needs to view the table structure and select the Table Inspector option to view the structure of the data table.
In the dialog box for viewing the data table, the Info tab displays the table name, storage engine, number of columns, table space size, creation time, update time, and character set proofing rules of the data table.
The Columns tab displays information about the data columns of the table, including column names, data types, default values, non-null IDs, character sets, proofreading rules, and usage rights.
Modify the data table
Right-click on the data table that needs to modify the table structure and select the "Alter Table ..." option to modify the basic information of the data table and the structure of the data table.
Delete data table
Right-click on the data table to be deleted and select "Drop Table ...".
In the pop-up dialog box, click the Drop Now button to delete the data table directly.
If you click the Review SQL button in the pop-up dialog box, you can display the SQL statement corresponding to the delete operation, and click the Execute button to execute the delete operation.

6. Use Workbench to edit the data in the table

Right-click on the name of the table to be edited and select Select Rows–Limit 1000 to edit the data in the table.
In the dialog box that pops up, the Edit menu bar contains three buttons, namely "Modify", "Insert" and "Delete". Click the Apply button to save the changes.
Insert picture description hereAfter setting in the dialog box for editing the data table, click the Apply button to preview the SQL script of the current operation, then click the Apply button, and finally click the Finish button directly in the next dialog box to complete the data table Modification of data.

Published 3 original articles · Likes0 · Visits 233

Guess you like

Origin blog.csdn.net/weixin_34007256/article/details/105608712