mysql version: mysql-5.7.17-winx64
There is no data directory after this version is decompressed
Proceed as follows:
1. Configure environment variables
My Computer -> Properties -> Advanced -> Environment Variables
D:\soft\mysql-5.7.17-winx64\bin Append this sentence to the path directory
2. Modify my-default.ini, or create a my.ini file by yourself
Add the following four sentences:
basedir=D:\soft\mysql-5.7.17-winx64
datadir=D:\soft\mysql-5.7.17-winx64\data
port = 3306
character_set_server=utf8
3. Run cmd as an administrator, execute mysqld -install, if the startup is unsuccessful, execute mysqld -console
will print the specific error message to the console
4. Start the mysql service and execute the command net start mysql
Note: If an error is reported, you can delete the original service and execute the command mysqld -remove
Can be executed, mysql -u root -p login
If prompted: mysqld: Can't change dir to 'D: oft\mysql-5.7.17-winx64\data\'
Then there are wrong characters in the my.ini directory, check carefully
5. Note that after the MySQL database is upgraded to version 5.7, it is somewhat different from the previous version. There is no data folder and needs to be executed. The following command generates the data directory. If it is not executed, it will prompt that mysql.user does not exist.
mysqld --initialize-insecure --user=mysql
If the prompt: mysql.plugin does not exist, execute bin/mysql_plugin.exe
---------------------------
Attach the command to modify the root password: the default password is empty
First enter the mysql command line mode
cmd, switch to the bin directory of mysql
Execute the command mysql -u root -p
Change root password
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
*It is important to note that there is no Password field in the user table under the new version of the mysql database.
Instead, store the encrypted user password in the authentication_string field
then execute the command
flush privileges
After quitting, restart mysql and you can log in again