MySQL配置

本想在Linux下安装配置进而熟悉下,但是考虑到Windowns下也有命令行cmd,就直接本机上搭建好了

1:下载

在官网下载看到了绿色版:http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.22-winx64.zip,就直接下载,当然还有exe,由于是open source所以还有源代码,有兴趣的可以自行操作

2:解压

直接解压就完毕了,目录:E:\mysql\mysql-5.6.22-winx64

3:选项文件

下载的这个mysql很多都是默认配置,有些需要重新配置一下,比如字符编码,在启动过程或者在选项文件中指定安装目录的路径等等,这些东西需要手动配置是因为下载的是ZIP,假如是安装的二进制exe文件,在安装的时候,一些下一步的时候可能就按照你的要求分别配置好了;而此时配置好了之后,mysql在启动的时候就会从配置文件中读取配置

新建一个my.ini,windows是通过后缀来确定文件类型,.ini是windows里的配置文件,保存了配置数据,my.ini需要添加下面几项:

[mysql]
#mysql client character
default-character-set = utf8

[mysqld]
#port
port = 3306
#basedir
basedir = E:\mysql\mysql-5.6.22-winx64
#datadir
datadir = E:\mysql\mysql-5.6.22-winx64\data
#max connections
max_connections = 200
#server character
character-set-server = utf8
#engine
default-storage-engine = INNODB

4:安装服务端

打开cmd,说实话这是我第一次用cmd来cd目录,找到了熟悉的linux感觉o(∩_∩)o,顺便发现了cmd内容的复制方法:鼠标右键点击边框,属性,选项里,编辑选项修改成快速编辑模式,然后如果想要copy内容的话,鼠标左键选中需要copy的内容,然后回车(复制快捷键)就行了,Windows用的少的忧桑~!

e:

cd mysql

cd mysql-5.6.22-winx64

E:\mysql\mysql-5.6.22-winx64\bin>mysqld install
Install/Remove of the Service Denied!

很不幸,看上去是权限问题,原来Windows也来管理员权限,试一试管理员打开cmd操作

E:\mysql\mysql-5.6.22-winx64\bin>mysqld install
Service successfully installed.

果然!接着就是启动服务了:

E:\mysql\mysql-5.6.22-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

这时候在任务管理器里的服务也能找到MySQL

5:启动mysql

首先设置mysql的root密码,这里就很奇怪了,原来失败不是设置失败

E:\mysql\mysql-5.6.22-winx64\bin>mysqladmin -u root -p password
Enter password: ***********
mysqladmin: connect to server at ‘localhost’ failed
error: ‘Access denied for user ‘root’@’localhost’ (using password: YES)’

E:\mysql\mysql-5.6.22-winx64\bin>mysqladmin -u root -p password
Enter password: ***********
New password: ***********
Confirm new password: ***********

接着直接登录吧:

E:\mysql\mysql-5.6.22-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.6.22 MySQL Community Server (GPL)

Copyright (c) 2000, 2014, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| taoyuangongyu      |
| test               |
+--------------------+
5 rows in set (0.00 sec)

mysql>

6:关闭服务

E:\mysql\mysql-5.6.22-winx64\bin>mysqladmin -u root -p shutdown
Enter password: ***********

E:\mysql\mysql-5.6.22-winx64\bin>

这下任务管理器查询MySQL就已经关闭了~!

发表回复