MySQL5.6安装步骤
1.下载MySQL Community Server5.6.37
2.解压MySQL压缩包
将以下载的MySQL压缩包解压到自定义目录下。例如 D:\Program Files\mysql-5.6.37-winx64
3.添加环境变量
我的电脑—属性—高级—环境变量
1)变量名:MYSQL_HOME
变量值:D:\Program Files\mysql-5.6.37-winx64
,即为mysql的自定义解压目录。
2)在Path中添加 %MYSQL_HOME%\bin
(用分号隔开)
4.注册windows系统服务
将mysql注册为windows系统服务
操作如下:
1)从cmd进入到MySQL解压目录下的 bin 目录下:
C:\Users\Administrator>cd D:\Program Files\mysql-5.6.37-winx64
C:\Users\Administrator>d:
D:\Program Files\mysql-5.6.37-winx64>cd bin
D:\Program Files\mysql-5.6.37-winx64\bin>
2)输入服务安装命令:
在管理员权限下
> mysqld install MySQL --defaults-file="D:\Program Files\mysql-5.6.37-winx64\my-default.ini"
> Service successfully installed.
安装成功后会提示服务安装成功。
注:my-default.ini文件在MySQL解压后的根目录下
移除服务命令为:mysqld remove
5.启动MySQL服务
方法一:启动服务命令为:net start mysql
方法二:打开管理工具 服务,找到MySQL服务
通过右键选择启动或者直接点击左边的启动来启动服务。
6.修改ROOT账号的密码
刚安装完成时root账号默认密码为空,此时可以将密码修改为指定的密码。如:123456
方法一:
在cmd中输入
c:>mysql –uroot
mysql>show databases;
mysql>use mysql;
mysql>UPDATE user SET password=PASSWORD("123456") WHERE user='root';
mysql>FLUSH PRIVILEGES;
mysql>QUIT
方法二:
利用第三方管理工具进行密码修改。如Navicat for MySQL
7 ROOT远程访问
在安装mysql的机器上运行:
//进入MySQL服务器
d:\mysql\bin\>mysql -h localhost -u root -p
//赋予任何主机访问数据的权限
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
//使修改生效
mysql>FLUSH PRIVILEGES;
//退出MySQL服务器
mysql>EXIT
8 授权
你想root使用123456从任何主机连接到mysql服务器。
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
如果你想允许用户xxx
从ip为10.81.112.41的主机连接到mysql服务器,并使用654321作为密码
mysql>GRANT ALL PRIVILEGES ON *.* TO 'xxx'@’10.81.112.41’ IDENTIFIED BY '654321' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
操作案例:
Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>cd D:\Software\Install\mysql-5.6.46-winx64
C:\Users\Administrator>cd D:\
C:\Users\Administrator>d:
D:\>cd Software\Install\mysql-5.6.46-winx64
D:\Software\Install\mysql-5.6.46-winx64>cd bin
D:\Software\Install\mysql-5.6.46-winx64\bin>mysqld install MySQL --defaults-file="D:\Software\Install\mysql-5.6.46-winx64\my-default.ini"
Service successfully installed.
D:\Software\Install\mysql-5.6.46-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
D:\Software\Install\mysql-5.6.46-winx64\bin>
Microsoft Windows [版本 6.3.9600]
(c) 2013 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.46 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.01 sec)
mysql> use mysql;
Database changed
mysql> UPDATE user SET password=PASSWORD("123456") WHERE user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
C:\Users\Administrator>mysql -h localhost -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.46 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'PD000731_陈麒'@’10.81.112.41’ IDENTIFIED BY '654321' WITH GRANT OPTION;
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>exit;
`