代码改变世界

mysql安装

2018-07-04 13:31  雄风狂飙  阅读(157)  评论(0编辑  收藏  举报

1.配置用户环境变量

新加环境变量MYSQL_HOME,指向安装目录。

MYSQL_HOME,

添加path %MYSQL_HOME%/bin

2.初始化mysql

D:\mysql-8.0.11-winx64\bin>mysqld --initialize-insecure --user=mysql

D:\mysql-8.0.11-winx64\bin>

3.启动mysql但报错

启动mysql服务的时候,在cmd输入:net start mysql

报错如下:

Enter password:

ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

 从网上搜了以下,据说有可能以下问题,一是是服务名称是mysql+后缀的东西,比如MYSQL85,但是经查不是这种情况;二是在mysql安装目录下面删除program文件,我压根没找到这个文件。后来在mysql的安装目录下面的bin目录下面发现有一个mysqld的空文件,删除以后,再启动,便成功了。

4.启动mysql

启动mysql服务的时候,在cmd输入:net start mysql,显示启动成功。

5.连接mysql

C:\WINDOWS\system32>mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.11 MySQL Community Server - GPL

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

mysql> select host,user,authentication_string from mysql.user;
+-----------+------------------+-------------------------------------------+
| host      | user             | authentication_string                     |
+-----------+------------------+-------------------------------------------+
| localhost | mysql.infoschema | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | mysql.session    | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | mysql.sys        | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
| localhost | root             |                                           |
+-----------+------------------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql>

ok,大功告成。