环境:
操作系统: Win7-32位
mysql版本:mysql-5.0.45-win32
安装步骤:
?1、在d:\mysql5下新建my.ini文件
[mysqld] # 设置mysql的安装目录 basedir=D:\mysql5 # 设置mysql数据库的数据的存放目录,必须是data,或者是\\xxx\data datadir=D:\mysql5\data # 设置mysql服务器的字符集 character-set-server=utf8 [client] # 设置mysql客户端的字符集 default-character-set=gbk
2、打开cmd,进入mysql解压目录D:/mysql5/bin下,输入命令
mysqld --console
?显示如下信息:
D:\mysql5\bin>mysqld --console 131001 18:13:23 InnoDB: Started; log sequence number 0 43655 131001 18:13:24 [Note] mysqld: ready for connections. Version: '5.0.45-community-nt' socket: '' port: 3306 MySQL Community Edition (GPL)
?表示mysql启动成功。
3、新开cmd窗口,输入命令:
D:\mysql5\bin>mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.0.45-community-nt MySQL Community Edition (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> status -------------- mysql Ver 14.12 Distrib 5.0.45, for Win32 (ia32) Connection id: 1 Current database: Current user: root@localhost SSL: Not in use Using delimiter: ; Server version: 5.0.45-community-nt MySQL Community Edition (GPL) Protocol version: 10 Connection: localhost via TCP/IP Server characterset: utf8 Db characterset: utf8 Client characterset: gbk Conn. characterset: gbk TCP port: 3306 Uptime: 7 sec Threads: 1 Questions: 4 Slow queries: 0 Opens: 12 Flush tables: 1 Open tabl es: 6 Queries per second avg: 0.571 -------------- mysql>
?完成。
?
?其他:
一、将mysql注册为系统服务:
?
D:\mysql5\bin>mysqld --install mysql5 --defaults-file=D:\mysql5\my.ini Service successfully installed. D:\mysql5\bin>net start mysql5 mysql5 服务正在启动 . mysql5 服务已经启动成功。?关闭:net stop mysql5
?
删除服务:mysqld --remove mysql5
二、修改root用户密码
?
D:\mysql5\bin>mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.5.34 MySQL Community Server (GPL) Copyright (c) 2000, 2013, 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> update mysql.user set password=PASSWORD('root') where user='root' or user =''; Query OK, 4 rows affected (0.03 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> grant all on *.* to root@'%' identified by 'root'; Query OK, 0 rows affected (0.02 sec) mysql> commit; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql>?附带mysql相关命令
附带mysql的一些简单操作: 第一招、mysql服务的启动和停止(针对安装版,或者压缩版已注册服务) net stop mysql net start mysql 第二招、登陆mysql 语法如下: mysql -u用户名 -p用户密码 键入命令mysql -uroot -p, 回车后提示你输入密码,输入12345,然后回车即可进入到mysql中了,mysql的提示符是: mysql> 注意,如果是连接到另外的机器上,则需要加入一个参数-h机器IP 第三招、增加新用户 格式:grant 权限 on 数据库.* to 用户名@登录主机 identified by "密码" 如,增加一个用户user1密码为password1,让其可以在本机上登录, 并对所有数据库有查询、插入、修改、删除的权限。首先用以root用户连入mysql,然后键入以下命令: grant select,insert,update,delete on *.* to user1@localhost Identified by "password1"; 如果希望该用户能够在任何机器上登陆mysql,则将localhost改为"%"。 如果你不想user1有密码,可以再打一个命令将密码去掉。 grant select,insert,update,delete on mydb.* to user1@localhost identified by ""; 第四招: 操作数据库 登录到mysql中,然后在mysql的提示符下运行下列命令,每个命令以分号结束。 1、 显示数据库列表。 show databases; 缺省有两个数据库:mysql和test。 mysql库存放着mysql的系统和用户权限信息,我们改密码和新增用户,实际上就是对这个库进行操作。 2、 显示库中的数据表: use mysql; show tables; 3、 显示数据表的结构: describe 表名; 4、 建