Solve the problem that Mysql 5.7. 17 prompt was unsuccessful when installing and starting under windows

  • 2021-07-26 09:00:57
  • OfStack

Install MySQL for the first time on the machine,

The operating system is win7

The installation file for mysql is in zip format, version 5.7. 17

After unzipping, the installation steps are

1. First find a file to store these installers and data

Assuming E:\\ mysql

2. Place the extracted file under E:\\ mysql and create a new data folder

3. Create environment variable mysql path is E:\\ mysql

Add to path% MYSQL%\ bin;

4. There is an my-default. ini under the extracted folder

First, make one copy and rename it as my. ini

Modify the contents of the file

Just modify two lines


basedir = E:\\mysql 
datadir = E:\\mysql\\data 

These two lines were originally commented out with #,

5. Start the command line as a system administrator

Input mysqld  -install

This is where the mysql service is installed

6. Enter mysqld --initialize

This is because after the automatic version 5.7. 7, windows installs mysql through zip decompression, and no longer contains data folder. Please refer to the introduction of official website for this

http://dev.mysql.com/doc/refman/5.7/en/windows-initialize-data-directory.html

If there is no data folder, you can't get up when you start mysql service. Observe the file with the suffix. err under data folder, and you can find that you will report some errors


MySQL: Table 'mysql.plugin' doesn't exist 
2017-01-01T17:13:33.200113Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 
2017-01-01T17:13:33.202113Z 0 [Note] Salting uuid generator variables, current_pid: 6908, server_start_time: 1483290810, bytes_sent: 0,  
2017-01-01T17:13:33.237115Z 0 [Note] Generated uuid: '9fb87162-d045-11e6-b092-00ff173a9c42', server_start_time: 1483297718, bytes_sent: 114009376 
2017-01-01T17:13:33.241115Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 9fb87162-d045-11e6-b092-00ff173a9c42. 
2017-01-01T17:13:33.248116Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 
2017-01-01T17:13:33.250116Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 
2017-01-01T17:13:33.254116Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 
2017-01-01T17:13:33.259116Z 0 [Note] IPv6 is available. 
2017-01-01T17:13:33.260117Z 0 [Note]  - '::' resolves to '::'; 
2017-01-01T17:13:33.261117Z 0 [Note] Server socket created on IP: '::'. 
2017-01-01T17:13:33.266117Z 0 [Warning] Failed to open optimizer cost constant tables 
2017-01-01T17:13:33.268117Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 
2017-01-01T17:13:33.270117Z 0 [ERROR] Aborting 

Actually, this is because these representations are placed in the data folder, so we need to execute the command first mysqld -initialize After completing the initialization of mysql, mysql will automatically complete some initialization work

7. Start the service net start  mysql


Related articles: