MySQL error — multiple methods of failed to find valid data directory and MySQL setting password appear

MYSQL error – Failed to find valid data directory

operating environment: windows10

database version: mysql.8.0.16

problem description:

MySQL service is starting.
MySQL service cannot start. The
service did not report any errors.


  • manually empty the files in the data folder under the installation path (possibly due to incomplete files due to previous initialization failure)
  • into the bin path remove mysql service
  • under the bin path enter mysqld –initialize-insecure (the program will create many files under the data folder)
  • continue to enter mysqld -install (service has been reinstalled)
  • start mysql service, enter net start mysql

the MYSQL error, Failed to find valid data directory. _Nikita – _failed CSDN blog to find valid data directory.




the mysql database password _qq_26486949 blog blog – CSDN _mysql password

mysql database password Settings

mysql newly installed does not have a password by default, so it needs to be set manually.

method 1: use the SET PASSWORD command

log in to MySQL first.

format: mysql> Set password for username @localhost = password(‘ new password ‘);

example: mysql> set password for root@localhost = password(‘123’);

method 2: mysqladmin

format: mysqladmin-u username -p old password password new password

example: mysqladmin-uroot-p123456 password 123

method 3: edit user table

directly with UPDATE

log in to MySQL first.

mysql> use mysql;

mysql> update user set password=password(‘123′) where user=’root’ and host=’localhost’;

mysql> flush privileges;

method 4: use the GRANT statement mysql> Grant all on *.* to ‘root’@’localhost’ IDENTIFIED BY ‘your password ‘with grant option; mysql> flush privileges;

method 5: when you forget the root password or initialize the password, you can do this:

Take Windows as an example:

1. Close the running MySQL service.
2. Open a DOS window and go to mysql\bin directory.

3. Enter mysqld –skip-grant-tables enter. Skip-grant-tables means to skip permission table authentication when starting MySQL service.

4. Open another DOS window (because the DOS window is no longer active) and go to the mysql\bin directory.
5. Enter mysql enter. If successful, mysql prompt &gt will appear. .

6. Connection permission database: use mysql; .

. Update user set password=password(“123″) where user=”root”; Don’t forget to put a semicolon at the end.

if ERROR 1054(42S22) Unknown column ‘password’ in ‘field list’ occurs, this is because the password field is no longer available in mysql database in version 5.7, and the password field is changed to authentication_string. The statement should be update User Set Authentication_string =password(“123″) where user=”root”;

7. Flush privileges (mandatory step) : flush privileges; .

8. Quit quit.
9. Log out of the system, enter again, log in with the username root and the new password 123 that you just set.

Read More: