Configure the installation-free version of Mysql

I encountered some troubles when downloading MySQL today, and it may be a common phenomenon, so I will post the solution here.
I downloaded the free version of Community Edition. So you need to configure it yourself.

1. Unzip
    the MySQL zip package Unzip the downloaded MySQL zip package to a custom directory, my unzip directory is:
    "D:\mysql"
    Copy the default file my-default.ini in the unzip directory and rename it my.ini
    Copy the following configuration information to my.ini and save #If
    there is no my-default.ini, you can create a new my.ini yourself or get it from other places
#################### ######################################
    [client]
    port=3306
    default-character-set= utf8
    [mysqld]
    port=3306
    character_set_server=utf8 #decompression
    directory
    basedir=D:\mysql #data
    directory under decompression directory
    datadir=D:\mysql\data

    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    [WinMySQLAdmin]
    D:\mysql\bin\mysqld.exe
############################################################################################################################################################################################################################################################################################################################################################################################################################### #####################

2. Add environment variables
    as follows:
    1) Right click on My Computer -> Properties -> Advanced System Settings (Advanced) -> Environment Variables
      Click the New button under System Variables to
      enter the variable name: MYSQL_HOME and
      enter the variable value: D:\mysql
      # is the custom decompression directory of mysql.
    2) Select Path in the system variable and
      click the edit button
      to add the variable value in the variable value: ;%MYSQL_HOME%\bin
      Note that this variable is added after the original variable value, separated by;, the original variable value cannot be deleted

3.
    1) Go to the bin directory under the MySQL decompression directory from the console:
    2) Enter the service installation command:
        1. mysqld --console
        2. mysqld --initialize
        3.
    After mysqld install is successfully installed, it will prompt the service installation is successful.
    #Note: #Execute these steps because there is no data folder in MySQL, you need to use these commands to generate the data folder
    #Remove the service command: mysqld remove
4. Start MySQL service
    Method 1:
        Start the service command as :net start mysql
    Method 2:
        Open the management tool service and find the MySQL service.
        Start the service by right-clicking and selecting Start or by clicking Start on the left.

5. Modify the password of the root account
        1. Modify the MySQL configuration file (my.ini), and add a line of skip-grant-tables under [mysqld]
        2. After mysql restarts, you can directly use mysql -u root -p to enter ( 3. mysql> update mysql.user set authentication_string=password(' 123qaz
        ') where user='root' and Host = 'localhost';

       4. mysql> flush privileges;
        5. mysql> quit;
        6 . Restore the /etc/my.cnf file (delete the skip-grant-tables line) and restart mysql
        7. At this time, you can use mysql -u root -p '123qaz' to enter
        8. mysql>SET PASSWORD = PASSWORD('123456'); Set a new password

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327073480&siteId=291194637