mysql-5.7.11-winx64的安装(win10)

版权声明:本博客可以随便转载,愿意注明出处就注明,不愿意也无所谓,学到就好。 https://blog.csdn.net/yuyongqun/article/details/82053167

今天安装个mysql竟然花了我将近20分钟,感觉太浪费时间了。

总结安装过程如下:

1、解压安装包到D:\Program Files\mysql路径下

2、添加环境变量,在path后面追加";D:\Program Files\mysql\mysql-5.7.11-win64\bin"

3、在D:\Program Files\mysql\mysql-5.7.11-win64目录下新建文件夹data

4、修改my-default.ini,如下:

basedir = D:\Program Files\mysql\mysql-5.7.11-winx64
datadir = D:\Program Files\mysql\mysql-5.7.11-winx64\data
port = 3306

5、以管理员身份打开cmd

6、安装服务

D:\Program Files\mysql\mysql-5.7.11-winx64\bin>mysqld --install
Service successfully installed.

7、初始化

D:\Program Files\mysql\mysql-5.7.11-winx64\bin>mysqld --initialize --console
2018-08-25T04:04:12.209977Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-25T04:04:14.706531Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-25T04:04:15.474311Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-25T04:04:15.709727Z 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: eeb3226f-a81b-11e8-b893-8cec4b4fdbd8.
2018-08-25T04:04:15.758038Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-08-25T04:04:15.770069Z 1 [Note] A temporary password is generated for root@localhost: p;wtGirNg5yk

注意:初始化完成后会默认随机提供一个root账户密码,例如我的是p;wtGirNg5yk

8、现在可以开启服务了

D:\Program Files\mysql\mysql-5.7.11-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

9、尝试直接按照以前的默认无密码的方式连接被拒绝了
D:\Program Files\mysql\mysql-5.7.11-winx64\bin>mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

10、还是得按套路输入密码,连接成功

D:\Program Files\mysql\mysql-5.7.11-winx64\bin>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.11

Copyright (c) 2000, 2016, 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.

11、然后想试试查看一下数据库,结果提示第一次要修改密码,那就修改一下呗

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> show databases
    -> ;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> update user set password=password('yjj314130') where user = 'root';
ERROR 1046 (3D000): No database selected
mysql> alter user 'root'@'localhost' identified by 'yjj314130';
Query OK, 0 rows affected (0.00 sec)

mysql>

12、 修改用户密码
mysql> alter user 'root'@'localhost' identified by 'heheda';  

或者       

mysql> set password=password("youpassword");
13、刷新一下权限
mysql> flush privileges;

接下来就可以正常使用了。
 

猜你喜欢

转载自blog.csdn.net/yuyongqun/article/details/82053167