天天看点

Windows下,MySQL的下载,安装与配置1、环境变量2、配置my.ini3、启动服务4、数据库操作

官方(GPL版)下载地址:http://dev.mysql.com/downloads/mysql/5.6.html

选择自己想要的版本(我选的是Windows (x86, 64-bit), ZIP Archive),点击Download。

在新打开的页面,直接点击下面的“No thanks, just start my download.”,便可下载。

下载后,直接解压,无需安装,然后进行配置,配置好后,即可使用。下面说说如何配置。

1、环境变量

添加 MYSQL_HOME:D:\Server\back\mysql-5.6.15-winx64

追加 PATH:%MYSQL_HOME%\bin;

2、配置my.ini

将my-default.ini该名为 my.ini,并在其中添加如下的语句:

[client]

default-character-set = utf8

port = 3306

[mysqld]

character_set_server = utf8

port = 3306

3、启动服务

用如下命令,进入MySQL的bin目录:

cd /d %MYSQL_HOME%/bin

用如下命令,安装(或卸载)系统服务:

mysqld install/remove

添加成功后,可以在任务管理器的服务栏中,找到MySQL。

用如下命令,启动(或停止)MySQL服务:

net start/stop mysql

4、数据库操作

可使用可视化界面工具(Navicat for MySQL)。

或者用MySQL的命令:

C:\Users\admin> mysql

mysql> help

mysql> help

For information about MySQL products and services, visit:
   http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
   http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
   https://shop.mysql.com/

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
notee     (\t) Don't write into outfile.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog
with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.

For server side help, type 'help contents'
           

新建的环境,是没有密码的,可以用如下方法设置密码:

# mysql -u root -p (-u: user; -p: password)

> show databases; (显示所有数据库;注意,最后有分号)

> use mysql;(使用mysql库)

> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';(更新root的密码)

> FLUSH PRIVILEGES; (刷新权限)

> quit(退出)

# mysql -u root -p(重新登录,测试密码是否好用)