MySQL 5.7.20 installation-free version configuration under Windows

  Take notes, lay the foundation, and go high. For your own reference, and corrections are welcome.

  1. Download the new version of the free installation file on the official website, mine is 5.7.20. Unzip to a custom directory.

  2. Configure environment variables: Right-click Computer-->Properties-->Advanced System Settings-->Environment Variables Add the directory where the bin folder is located at the end of the path, such as: ;D:\Program Files\mysql\bin. Note: This directory is connected with the original path content with a semicolon (;).

  3. Modify the configuration file: The default configuration file path is D:\Program Files\mysql\my-default.ini. If not, create a new my.ini file by yourself. Open, add or modify the following:
    [mysqld]
    # mysql installation directory
    basedir=D:\Program Files\mysql
    # mysql installation directory\data
    datadir=D:\Program Files\mysql\data
  4. Run cmd as an administrator (otherwise, system error 5 will be reported), and enter the following commands in sequence:
  • cd D:\Program Files\mysql\bin #Must enter the bin folder first
  • mysqld --initialize #Directly initialize mysql and generate files in the data folder.
  • mysqld -install #install mysql
  • net start mysql #Start the server

    The mysql server started successfully.

  5. Log in to mysql.
    Enter the mysql -uroot -p command to log in, but do not know the login password. In this case, you need to reset the password according to the following steps:
1) Open the my.ini file, and add a new line under [mysqld]: skip-grant-tables, And save, skip the authorization verification method to start mysql.
2) Restart mysql:
  1. Run cmd as administrator
  2. Stop the service: net stop mysql 
  3. Start the service: net start mysql 

3) Enter mysql -uroot -p again, and press Enter when password: appears, you can log in without entering a password.

   At this point, mysql has been successfully installed and logged in successfully. But the password needs to be reset. The password field in the original user has become authentication_string in the new version (5.7.x) mysql
  6. Enter the mysql database and set a new password for the root user
1) Enter the mysql database
    mysql> use mysql
2) Set a new password for the root user
mysql> update user set authentication_string=password('password') where user='root' and Host = 'localhost';
3) flush database
mysql> flush privileges;
4) exit database
    mysql> exit

5) Delete the new line of code in the my.ini file: skip-grant-tables, save it, and restart mysql.

  7. Although mysql can log in, some operations will report errors, such as
    mysql> show databases;
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. You
  
  need to execute mysql> alter user 'root '@'localhost' identified by 'password';
  then log out and log in to mysql again to use it.
  
  
  
  
  
  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324813501&siteId=291194637