如果出现以下错误:
- D:\mysql-5.7.19-winx64\bin>net start mysql
- MySQL 服务正在启动 .
- MySQL 服务无法启动。
- 服务没有报告任何错误。
- 请键入 NET HELPMSG 3534 以获得更多的帮助。
- D:\mysql-5.7.19-winx64\bin>mysqld --initialize
- D:\mysql-5.7.19-winx64\bin>net start mysql
- MySQL 服务正在启动 .
- MySQL 服务已经启动成功。
- 2017-09-07T09:37:03.899377Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
- 2017-09-07T09:37:04.569889Z 0 [Warning] InnoDB: New log files created, LSN=45790
- 2017-09-07T09:37:04.679042Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
- 2017-09-07T09:37:04.772602Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 1bc80410-93b0-11e7-9439-00fff97c2448.
- 2017-09-07T09:37:04.788195Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
- 2017-09-07T09:37:04.803789Z 1 [Note] A temporary password is generated for [email protected]: jole/W*_Z6rn
3.验证是否安装成功
如果看到说MySQL 服务正在启动 .一直这样显示,直接回车就行了,会显示启动成功。服务启动成功之后,就可以登录了,mysql -u root -p回车之后,提示输入密码,输入上面生成的随机密码,
- D:\mysql-5.7.19-winx64\bin>mysql -u root -p
- Enter password: ************
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 6
- Server version: 5.7.19
- Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
- Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
4.修改密码
对于windows平台来说安装完MySQL数据库后,系统就已经默认生成了许可表和账户,你不需要像在Unix平台上那样执行 mysql_install_db脚本来生成帐户和相应权限许可表。但是如果不是用MSI格式来安装MySQL的话,就需要在安装完以后,手动给root帐户添加新密码,因为默认情况下的root没有开启密码保护功能,如果不重新赋予root帐户密码,那么许多非本机的连接将无法成功。
方法1:用SET PASSWORD命令,具体更新密码步骤如下:
- c:>mysql -u root
- mysql>set password for ‘root‘@‘localhost‘=password(‘newpasswd‘)
- mysql>set password for ‘root‘@‘%‘=password(‘newpasswd‘) //本条可选
通过以上设置,root的密码将变为newpasswd这样就完成了根用户root密码的设置工作。
方法2:用mysqladmin
- mysqladmin - u root password "newpass"
如果root已经设置过密码,采用如下方法:
- mysqladmin - u root password oldpass "newpass"
方法3: 用UPDATE直接编辑user表
- mysql -u root
- mysql> use mysql;
- mysql> UPDATE user SET Password = PASSWORD(‘newpass‘) WHERE user = ‘root‘;
- mysql> FLUSH PRIVILEGES;
在丢失root密码的时候,可以这样
- mysqld_safe --skip-grant-tables&
- mysql -u root mysql
- mysql> UPDATE user SET password=PASSWORD("new password") WHERE user=‘root‘;
- mysql> FLUSH PRIVILEGES;
方法4:用ALTER USER的方法编辑user表
- ALTER USER‘root‘@‘localhost‘IDENTIFIED BY‘password‘
就这么简单就完成了MySQL数据库默认密码的修改,默认密码修改了之后大家就可以进行更多的操作了。
4.退出数据库
MySQL退出的三种方法:
- mysql > exit;
- mysql > quit;
- mysql > \q;
来源: http://www.bubuko.com/infodetail-2296719.html