《Mysql入门Windows平台配置5.7版本+MySQL数据库服务》要点:
本文介绍了Mysql入门Windows平台配置5.7版本+MySQL数据库服务,希望对您有用。如果有疑问,可以联系我们。
MYSQL必读包括初始化root用户密码password的过程以及两个常见问题的解决方法
MYSQL必读1. 下载MySQL zip包
MYSQL必读进入[MySQL官网](http://dev.mysql.com/downloads/mysql)按需选择zip包下载并解压,
MYSQL必读比如现在我电脑里面下载的是mysql-5.7.17-winx64
MYSQL必读http://dev.mysql.com/downloads/mysql/
MYSQL必读2. 编辑MySQL配置文件
MYSQL必读打开解压的mySQL.zip包,在里面找到my-defalult.ini, 该文件是MySQL的默认配置文件
MYSQL必读此处推荐大家复制一份,并改名my.ini
MYSQL必读编辑my.ini,此处我只配置了端口,MySQL的安装目录以及MySQL数据库存放目录
MYSQL必读
> [mysqld]
> # 设置3306端口
> port = 3306
> # 设置MySQL的安装目录
> basedir=C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64
> # 设置MySQL数据库的数据的存放目录
> datadir=C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\data
MYSQL必读3. 安装并配置MySQL服务
MYSQL必读使用admin权限打开CMD运行窗口,进入到MySQL的bin目录下执行以下install命令
MYSQL必读
C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>mysqld -install
Service successfully installed.
MYSQL必读运行net start mysql命令打开MySQL服务
MYSQL必读
net start mysql
MYSQL必读PS:问题1
MYSQL必读描述:启动MySQL服务失败
MYSQL必读
C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>net start mysql
The MySQL service is starting.
The MySQL service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534.
MYSQL必读解决方法:
MYSQL必读通过一些网络上面的搜索得知,版本5.7以后在启动MySQL服务前,需要初始化bin\data目录,
MYSQL必读我的做法是:
MYSQL必读
- 创建bin\data目录,如果存在删掉以前的
- 在刚刚的admin权限的运行窗口执行初始化命令,以此来生成没有密码的root用户:
C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>mysqld --initialize-insecure
- 再次尝试打开MySQL服务,不出意外,会返回success:
C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>net start mysql
The MySQL service is starting.
The MySQL service was started successfully.
MYSQL必读检查MySQL服务已经打开
MYSQL必读运行net start命令列出所有已经打开的windows服务,在输出中找到MySQL代表成功:
MYSQL必读
C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>net start
These Windows services are started:
...
MySQL
...
MYSQL必读4. 初始化root用户密码
MYSQL必读进入MySQL
MYSQL必读由于我们刚刚生成的root没有附带密码,所以可以通过以下命令免密码进入MySQL
MYSQL必读
mysql -u root
MYSQL必读选择使用MySQL数据库
MYSQL必读
mysql> use mysql;
MYSQL必读通过sql语句查看user表数据, 可以确定目前root无密码
MYSQL必读
mysql> select user, authentication_string from user;
+-----------+-------------------------------------------+
| user | authentication_string |
+-----------+-------------------------------------------+
| root | |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+-----------+-------------------------------------------+
2 rows in set (0.00 sec)
MYSQL必读为MySQL root用户初始化密码
MYSQL必读
mysql> update user set authentication_string=password('密码') where user='root';
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 1
MYSQL必读PS:问题2
MYSQL必读描述:使用以下命令初始化密码失败
MYSQL必读
mysql> update user set password=PASSWORD('密码') where user='root';
MYSQL必读解决方法:
MYSQL必读可以通过查看user表信息得知,在新版的MySQL的user表中,已经去除掉了password字段,
MYSQL必读而用authentication_string替换,因此使用该的命令,会返回错误.
MYSQL必读再次确认user表下面的root用户信息,可以看到现在root用户已经拥有了密码.
MYSQL必读
mysql> select user, authentication_string from user;
+-----------+-------------------------------------------+
| user | authentication_string |
+-----------+-------------------------------------------+
| root | *8B62E5775164CCBD6B3F9FFFC5ABCEFGHIGKLMNO |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+-----------+-------------------------------------------+
2 rows in set (0.00 sec)
MYSQL必读执行flush privileges命令使更改生效
MYSQL必读
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
MYSQL必读退出MySQL
MYSQL必读
mysql> exit
Bye
MYSQL必读使用root密码登陆MySQL
MYSQL必读
C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>mysql -u root -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.17 MySQL Community Server (GPL)
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.
mysql>
MYSQL必读以上所述是小编给大家介绍的Windows平台配置5.7版本+MySQL数据库服务,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的.在此也非常感谢大家对维易PHP网站的支持!
转载请注明本页网址:
http://www.vephp.com/jiaocheng/5254.html