Successful mysql remote connectivity

1, install mysql in window7 on the virtual machine, version mysql-5.7.27-win32, can be decompressed version or installation version,

MySQL installation files are divided into two types, one is the msi format, one is zip format. If msi format can click installation, follow the installation prompts it gives the general MySQL will be installed in C: \ Program Files \ MySQL \ MySQL Server 5.6 that directory; zip format is its own decompression, decompression after In fact, you can use MySQL, but should be configured.

The following version of the installation of the decompression explain:

1. First decompress.

2. Create a new data folder in the installation directory.

3. New my.ini configuration file in the installation directory.

# Start Code 
[Client] 
# 3306 port disposed 
Port = 3306  

[mysqld] 
# 3306 port disposed 
Port = 3306  
# mysql installation directory setting 
the basedir = D: \ MySQL- 5.7  
# mysql database setting data storage directory 
DATADIR = D: \ MySQL- 5.7 / Data 
# maximum number of connections 
max_connections = 200 is  
# character set used by the server defaults to the 8-bit coded character set latin1 
character - sET -server = UTF8 
default storage engine # create a new table will be used when the 
default - Engine-= Storage INNODB 
the sql_mode = NO_ENGINE_SUBSTITUTION, the STRICT_TRANS_TABLES

[mysql] 
# mysql client set the default character set 
default -character- SET = UTF8 
End Code #

 


4. Environment Variables

Edit System Variable Path: add the MySQL bin directory inside.

5. Command Prompt with Run as Administrator cmd. (If you do not run as administrator, it will be because of insufficient permissions error: Install / Remove of the Service Denied!) 

6.cd to the bin directory of MySQL.

7. Run the following three statements:

mysqld --defaults-file=my.ini --initialize-insecure

mysqld --install

net start mysql

 


8. Use mysql -u root -p database login prompts for a password or a direct connection with Navicat GUI will complain if:

   ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password)

 

The initial password to view and modify the method:

1. After the initial installation of the database and start the service, you need to first shut down the server (Explorer or "My Computer" - "service" to close)

2.mysql \ data directory, generated a .err file (equivalent log log files under linux, this file will be occupied by mysql service)

 

 

 

 

 

 

 

 

 

4. Write down your passwords, restart the MySQL service, and enter CMD command line, as used herein mysql -u root -p login, type the password

5. After entering the database, using the set password for root @ localhost = password ( 'your password'); login password reset

At this time, instead of using the update, update method of updating user authentication data is skipped.

6. Tip Query OK, modified successfully, then you can try to log in again.

 

Here is the installation version (5.5) Detailed installation:

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

Visit the official network click:

 

 

 

 

Select Version:

 

 

 

 

After clicking the Download button, you will jump page: 

 

 

 

 

After downloading to begin the installation steps:

Step 1: Select the type of installation

There are three types of installation: Typical (typical installation), Complete (fully installed), and Custom (custom installation).

Typical (Typical installation) install only install MySQL server, mysql command-line client and command-line utilities. Command-line client and utilities include mysqldump, myisamchk, and several other tools to help you manage the MySQL server.

Complete (full installation) installation will install all the components contained within the package. Full installation package includes components include an embedded server library, the benchmark suite, support scripts and documentation.

Custom (custom installation) installation packages and allows you complete control over the installation path you want to install.

 

 

 

 

 

 

Step 2: Custom Installation Dialog

All available components included in the tree view on the left side of the dialog box a custom installation. Component is not installed are indicated by a red X icon; components are already installed have a gray icon. To change a component, click the component icon and select a new option from the drop-down list.

You can click the right side of the installation path of Change ... button to change the default installation path.

After selecting the installation components and installation path, click the Next button to enter the confirmation dialog.

After installed you need to configure the mysql:

 

 

 

 

Step 3: configuration type

You can choose between two types of configuration: Detailed Configuration (Detailed Configuration) and Standard Configuration (standard). Standard Configuration (standard configuration) options for want quick start MySQL without having to consider new user server configuration. For more configuration options for advanced users want more fine-grained control of server configuration.

If you are new to MySQL and need a server configured as a single-user development machine, Standard Configuration (standard configuration) should suit your needs. Select Standard Configuration (standard configuration) option, the MySQL Configuration Wizard (Configuration Wizard) automatically set all configuration options, but does not include service options and security options.

Standard Configuration (standard configuration) setup option may not meet our needs. If the system has a different version of the MySQL installation, it is recommended to select detailed configuration.

 

 

 

 

Step 4: Select the server type

Choice of 3 server type, choose which server will affect the MySQL Configuration Wizard (configuration wizard) decisions on memory, disk, and process or use.

Developer Machine (development machine): This option represents the typical personal desktop workstations. Running multiple applications on a desktop machine is assumed. The MySQL server is configured to use a minimum of system resources.
Server Machine (server): This option represents the server, MySQL server can be run in conjunction with other applications, such as FTP, email and web servers. MySQL server is configured to use an appropriate proportion of system resources.
Dedicated MySQL Server Machine (dedicated MySQL server): This option represents the only server running MySQL services. Assuming that runs without running other applications. MySQL server is configured to use all available system resources.
 

 

 

 

 

Step 5: Select Save Engine

You can point table processor to use when creating MySQL tables. With this option, you can choose whether to use the InnoDB storage engine, InnoDB, and server resources occupied by what percentage.

Multifunctional Database (multi-function database): Select this option, then use both InnoDB and MyISAM storage engine, and equal distribution of resources between the two engines. It recommends that users regularly use two storage engines choose this option.
Transactional Database Only (only transactional database): This option InnoDB and MyISAM storage using both engines, but to assign most server resources to the InnoDB storage engine. The main use is recommended only occasionally use InnoDB MyISAM user selection of the option.
Non-Transactional Database Only (only non-transactional database): This option disables the InnoDB storage engine, will assign all server resources to the MyISAM storage engine. InnoDB is not recommended users select this option.
Here briefly, InnoDB and MyISAM in MySQL using the two most commonly used types of tables, each with advantages and disadvantages, depending on the specific application. The basic difference is: MyISAM type of advanced processing transactions, which do not support, and support for InnoDB type. MyISAM table type to emphasize that performance, which performs several times faster than InnoDB type, but does not provide transaction support, and InnoDB provides transaction support and foreign keys and other advanced database features.

 

 

 

 

 

Step 6: Select the InnoDB data file storage directory

 

 

 

 

Step 7: Set concurrent connections provided

The number of concurrent connections between the server and the MySQL restrictions created is important in order to prevent the server from running out of resources.

Decision Support (DSS) (DSS) / OLAP: If the server does not require a large number of concurrent connections can select this option. Assuming that the average number of concurrent connections 20.
Online Transaction Processing (online transaction processing) (OLTP): If your server requires a large number of concurrent connections Select this option. The maximum number of connections is set to 500.
Manual Setting (manual setting): Select this option parallel manually set maximum number of connections the server. Number of drop-down box in front of a parallel connection, if you are not in the list the desired number, then enter the maximum number of connections in the drop-down box.
 

 

 

 

 

Step 8: networking options

You can enable or disable the TCP / IP network Networking Options (network options) dialog box, and configure the port number used to connect to the MySQL server. By default, enable TCP / IP network. To disable TCP / IP networking, uncheck the next to Enable TCP / IP Networking Options check box.

Use the default port 3306. To access more MySQL port used to select a new port number or enter a new port number directly to the drop-down box from the drop-down box. If you choose port number is already occupied, you will be prompted to confirm your choice of port number.

 

 

 

 

 

Step 9: Select the character set

MySQL server supports multiple character sets, you can set applies to all tables, columns, and the database server default character set. To change the default character set of the MySQL server using the Character Set (Character Set dialog box).

Standard Character Set (standard character set): If you want to use the Latin1 character set as the default server, select this option. Latin1 for English and many Western European languages.
Best Support For Multilingualism (in multiple languages): If you want to use the UTF8 character set as the default server, select this option. UTF8 characters in different languages can be stored as a single character set.
Manual Selected Default Character Set / Collation (manual selection of the default character set / collation): If you want to manually select the server's default character set, select the item. Select the desired character set from the drop-down list.
I am in the process of configuration, only need to modify the Manual Selected Default Character Set / Collation to utf8

 

 

 

 

 

Step 10: Setting Service

On the Windows NT-based platform, MySQL server can be installed as a service. Can start automatically with Windows when installed as a service, you can start the MySQL server automatically at system startup, and even service failure.

By default, MySQL Configuration Wizard (Configuration Wizard) to MySQL server installed as a service, the service name MySQL. If you do not want to install the service, uncheck the box next to the Install As Windows Service option. You can select a new service name from the drop-down box or enter a new service name in the drop-down box to change the service name.

To install the MySQL server as a service, but does not start automatically, do not select the check box next to the Launch the MySQL Server Automatically option.

Include Bin Directory in Windows PATH, then select the bin directory is speaking on the windows of the path, we can use the bin directory of the executable file from the command line

 

 

 

 

 

Step 11: Security Options

It is strongly recommended to set a root password for your MySQL server, by default MySQL Configuration Wizard (Configuration Wizard) requires you to set a root password. If you do not want to set the root password, do not check the box next to (to modify the security setting value) option Modify Security Settings.

To set the root password, in the New root password (Enter your new password) and Confirm (confirmation) Enter the desired password two boxes. If you reconfigure an existing server, you also need Current root password (current root password) enter the existing root password box.

To prevent the network login, do not check the box next to access the option Enable root from remote machines (not allow remote connections). This improves security.

To create an anonymous user account, select Create An Anonymous Account (create an anonymous account) the box next to the option. Create an anonymous account will reduce the security of the server and cause login and permission difficulties. Therefore not recommended.

 

 

 

 

Step 12: here all the configuration operations have been completed, click the Execute button to perform the configuration.

 

 

 

 

Step 13: After a few minutes, the following prompt appears on behalf of MySQL interface configuration has ended, and prompts a message of success.

 

 

2, after the local dos able to successfully connect to mysql database, remote connection attempts, the following configuration

Set up remote access mode

Mysql default is not accessible by remote machines, you can turn on the remote access via the following configuration in MySQL Server side: the implementation of mysql command to enter the mysql command mode, 

 

 

Sql Code 
  1. mysql> use mysql;   
  2. mysql> GRANT ALL ON *.* TO user@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;   

# What this means, allows any IP address (% above what it means) computer with admin account and password (admin) to access the MySQL Server   

# Like this must be added the account before they can log in remotely. The root account is not remote landing, the landing can only be local  

remote access:

  1. mysql -h172.21.5.29 -uuser -p123456 to the
  2. //172.21.5.29 is the IP address of the MySQL Server, user remote access account is just set on 172.21.5.29

  Alternatively you can simulate remote access on a machine, it is to open several terminals, convenient test whether remote access.

 

 

 

3, when the mysql log log format   

 

1 Connect 
    a local connection: 
        MySQL -u root - the p-Enter 
        the password 
    to connect remotely: 
        MySQL -h ip -u account - the p-Enter 
        MySQL -h 127.0 . 0.1 -u root - the p-
         remote connection, must be authorized

 

  Remote connections must be authorized: specific authorization process, see the second part of this post: (after 2, under local dos able to successfully connect to mysql database, try a remote connection)

 

 

 

Reference https://www.cnblogs.com/jycboy/p/6770069.html

Guess you like

Origin www.cnblogs.com/isme-zjh/p/11541968.html