关于新建MySQL数据库时遇到部分问题

一.连接数据库时发生如下错误:

C:\DataBase\Mysql\bin>mysqld --initialize --console
2019-05-10T02:09:58.237026Z 0 [Warning] option ‘wait_timeout’: unsigned value 31536000 adjusted to 2147483
2019-05-10T02:09:58.237085Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-05-10T02:09:58.239285Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-05-10T02:09:58.240073Z 0 [ERROR] Aborting

关于新建MySQL数据库时遇到部分问题
1.这个问题错误的原因是在data文件下不为空,所以会报这样的错误,当我们去删除文件夹里的内容时,发现无法删除。是因为mysql在本地是运行状态的原因。

2.进入到本地服务将MYSQL关闭。之后就发现可以将data 文件下的内容删除。

3.之后用管理员运行cmd文件,进入MySQL的bin目录。
4. 此时执行mysqld --initialize –console初始化命令,就可以发现我们得到了初始化密码。

关于新建MySQL数据库时遇到部分问题

二.

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘123456’:’ at line 2
关于新建MySQL数据库时遇到部分问题
此类错误是因为语法上的问题导致的,可以到正确的重置数据库密码语句为: alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘123456’;
关于新建MySQL数据库时遇到部分问题
之后显示如上则重置成功。