Installing MySQL5.7.18 encounters the Pit

Source: Internet
Author: User

Recently noticed that the differences between the various versions of MySQL are quite large, such as the 5.5.x version of the timestamp type column can only have one set to default Current_timestamp, so try to replace a new version is MySQL, But do not want to move the local original database, so want to install on my win7 system two MySQL data, so stepped on the following several pits.
I installed the version is mysql-5.7.18-winx64 decompression version, in addition to the online installation of a lot of tutorials, I am not here nonsense. I refer to a written more detailed document: MySQL installation tutorial, write good, but here said My.ini in the bin is not very accurate, actually placed in the same level as the Bin directory, of course, this directory location is configurable.
Pit One: Run mysqld Direct report Msvcr120.dll can't find, Solution: Online can download https://www.microsoft.com/en-us/download/confirmation.aspx?id= 40784, and then start running "regsvr32 msvcr120.dll" to complete the registration, many posts do not say this, do not know the intentions?
Pit two: Because I have installed the local MySQL, so this new installation name service can not be called MySQL, so I installed with Mysqld-install called: mysql5.7, the results when the discovery said "a system error 2 occurred." The system could not find the file. ”。 Many people on the internet said it was because of the registry, I checked the registry found that the "ImagePath" property of the registry does not specify the mysqld executable file, pointing to the C drive, I actually in the D disk, and thus in accordance with the requirements of the online modification, the results do not report the file can not find the error, But the start or failure, more unfortunate is the error is not reported, but the start of the failure, and then I deleted the re-engage, and finally I carefully compared to find out when the user installed the service name does not ".", so I called the "Mysql7", it was done, the service started successfully, It is obvious that this is inadvertently encountered a bug, the Netizen said is a situation, I encountered is a more complicated situation, the conclusion: the name of the service do not add ".", I think it is best not to use other special symbols (here is estimated operating system requirements, not detailed, some years ago encountered a similar problem, Because the service name is too long).
Pit three: In the use of "Navicat" when imported, reported "2006-mysql Server has gone away" error, this time because the Sql_mode setting is not correct, this reason is: MySQL5.7 default value is not compatible with the problem. Workaround: Add the following under [Mysqld] as follows: "Sql_mode=only_full_group_by,strict_trans_tables,error_for_division_by_zero,no_auto_ Create_user,no_engine_substitution "
Pit IV: 2006-mysql server has gone away, this is because the value of max_allowed_packet is too small, the workaround, under [mysqld], add the following as follows: Max_allowed_packet = 256M, The speed at which data is imported is also significantly increased.
Pit Five: 1265-data truncated for column, this is because the value of the inverted data column is incorrect, for example, the gender is using the enum type, but the imported data value is empty. Here I use Navicat to import the PSC format backup data, the workaround: Use the "Extract SQL" in the Navicat backup to export to a text file to modify the value of the column below.

CD bin
Mysqld--install MySQL
net start MySQL

Download MySQL

Https://dev.mysql.com/downloads/mysql/5.1.html#downloads

The personal machine is 64-bit, so choose Download: Windows (x86, 64-bit), ZIP Archive version

Unzip and install

Extract the downloaded package to the specified directory, (i) extracted to: D:\Program Files (x86) directory.
Therefore, the full path to the MySQL (install) package is: D:\Program Files (x86) \mysql-5.7.18-winx64

After decompression, configure the system environment variables.
New system Environment variables:
Key Name: Mysql_home
Values are: D:\Program Files (x86) \mysql-5.7.18-winx64
Then add in Path:%mysql_home%\bin

After extracting, prepare the My.ini file.
Note: (said) the previous version of the decompression, in the Extract directory will have My-default.ini or My.ini files, however, v5.7.18 version of the decompression, there is no such files. Therefore, you need to manually create a good My.ini file, the specific (complete) content of the file is as follows:
Press CTRL + C to copy the code

[Client]
port=3306
Default-character-set=utf8
[Mysqld]
port=3306
Character_set_server=utf8
Basedir=%mysql_home%
Datadir=%mysql_home%\data
[Winmysqladmin]
%mysql_home%\bin\mysqld.exe
Press CTRL + C to copy the code
After editing the My.ini file, place the My.ini in the bin directory.

Open the CMD Command window as an administrator and cut the directory into the bin directory under the MySQL installation package

To install the MySQL database, execute the following command:
Mysqld.exe-install
After executing the command, prompt: Service successfully installed. Indicates successful installation
Initialize the MySQL data and create a root user with a blank password, and execute the following command:
Mysqld--initialize-insecure--user=mysql
Note: The last parameter--user=mysql may not be added in Windows, but it seems to be important under UNIX and other systems.
After the command is executed, after a while, the system automatically generates the corresponding data directory and automatically creates the root user for the empty password. This indicates that the initialization was successful.

Start the MySQL service and execute the following command:
net start MySQL
After execution, prompt:
The MySQL service is starting:
The MySQL service has started successfully.
Note: To log in using MySQL, the service is required to be started first. The same is true later.

After the service starts, because the root user you just created is a blank password, you need to set the password first. Execute the following command:
Mysqladmin-u root-p Password Enter a new password here
Enter Password: Enter the old password here
After executing the above two commands, as long as enter password: After entering the old password is correct, the root user's new password even if the setting is successful. Thereafter, to log in to the root user, you will need to use the new password.
Note: The root user that you just created is a blank password, so when you first modify the root user's password, enter password: After entering no password, you can return directly.

At this point, the decompression installation of MySQL v5.7.18 has been completed, so you need to stop the previously started MySQL service, execute the following command:
net stop MySQL
Log in and use MySQL

The previous installation of MySQL database, as long as the installation is successful, you can log in to the root user, and data related operations, such as: Build table, add, delete, change, check and so on. The following is a simple process:

Open cmd as Administrator and cut to the bin directory of the MySQL installation directory
net start MySQL//Description: The command is to start the MySQL service
Mysql-u root-p//Description: This command is logged in to the root user
Enter Password: The password of the root user that was previously set
After the correct login, you can manipulate the data such as: increase, delete, change, check and so on. Example:
mysql> show databases; Show all databases
Mysql> the SELECT statement .....
...
To exit the user and stop the service when the database is no longer in use, execute the following command:
Mysql> quit;
net stop MySQL

Deleting a database

If you no longer want to use MySQL, you can execute the following command:
Mysqld--remove

Installing the pits encountered by MySQL5.7.18

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.