MySQL5 绿色版安装教程

MySQL5 绿色版安装教程

内容提要:mysql-noinstall-5.0.67-win32.zip的安装教程

一、下载,这里使用绿色解压缩版

[url]http://mysql.west.mirrors.airband.net/Downloads/MySQL-5.0/mysql-noinstall-5.0.67-win32.zip[/url]

二、配置MySQL5的参数

1、解压缩绿色版软件到D:\mysql-5.0.67-win32
2、修改D:\mysql-5.0.67-win32\my-small.ini文件内容,添加红色内容

[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[color=red]default-character-set=gbk[/color]

[mysqld]
port = 3306
socket = /tmp/mysql.sock
[color=red]default-character-set=gbk[/color]
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K

3、安装MySQL5的服务,服务名自己定义为MySQL5.
1)、在DOS窗口下进入D:\mysql-5.0.67-win32\bin目录
2)、执行安装MySQL服务名的命令:
D:\mysql-5.0.67-win32\bin>[color=red]mysqld --install MySQL5 --defaults-file=D:\mysql-5.0.67-win32\my-small.ini[/color]

Service successfully installed.

3)、启动MySQL5服务
D:\mysql-5.0.67-win32\bin>[color=red]net start mysql5[/color]
MySQL5 服务正在启动 .
MySQL5 服务无法启动。

4)、登陆MySQL5服务器
D:\mysql-5.0.67-win32\bin>[color=red]mysql -uroot -p[/color]
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.67-community MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

注意:MySQL5的管理员用户名为root,密码默认为空。

5)、查看数据库
mysql> [color=red]show databases;[/color]
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)

可以看到MySQL服务器中有三个数据库。

6)、使用数据库
mysql> [color=red]use test[/color]
Database changed

7)、查看数据库中的表
sql> [color=red]show tables;[/color]
Empty set (0.00 sec)

8)、创建表ttt
mysql> [color=red]create table ttt(a int,b varchar(20));[/color]
Query OK, 0 rows affected (0.00 sec)

9)、插入三条数据
mysql> [color=red]insert into ttt values(1,'aaa');[/color]
Query OK, 1 row affected (0.02 sec)

mysql> [color=red]insert into ttt values(2,'bbb');[/color]
Query OK, 1 row affected (0.00 sec)

mysql> [color=red]insert into ttt values(3,'ccc');[/color]
Query OK, 1 row affected (0.00 sec)

10)、查询数据
mysql> [color=red]select * from ttt;[/color]
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
| 3 | ccc |
+------+------+
3 rows in set (0.00 sec)

11)、删除数据
mysql> [color=red]delete from ttt where a=3;[/color]
Query OK, 1 row affected (0.01 sec)

删除后查询操作结果:
mysql> [color=red]select * from ttt;[/color]
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
+------+------+
2 rows in set (0.00 sec)

12)、更新数据
mysql> [color=red]update ttt set b = 'xxx' where a =2;[/color]
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

查看更新结果:
mysql> [color=red]select * from ttt;[/color]+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | xxx |
+------+------+
2 rows in set (0.00 sec)

13)、删除表
mysql> [color=red]drop table ttt;[/color]
Query OK, 0 rows affected (0.00 sec)

查看数据库中剩余的表:
mysql> [color=red]show tables;[/color]
Empty set (0.00 sec)


三、更改MySQL5数据库root用户的密码

1、使用mysql数据库
mysql> [color=red]use mysql[/color]
Database changed

2、查看mysql数据库中所有的表
mysql> [color=red]show tables;[/color]
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| func |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| proc |
| procs_priv |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
17 rows in set (0.00 sec)

3、删除mysql数据库中用户表的所有数据
mysql> [color=red]delete from user;[/color]
Query OK, 3 rows affected (0.00 sec)

4、创建一个root用户,密码为“xiaohui”。
mysql> [color=red]grant all on *.* to root@'%' identified by 'xiaohui' with grant option;[/color]
Query OK, 0 rows affected (0.02 sec)

5、查看user表中的用户
mysql> [color=red]select User from user;[/color]
+------+
| User |
+------+
| root |
+------+
1 row in set (0.00 sec)

6、重启MySQL5:更改了MySQL用户后,需要重启MySQL服务器才可以生效。
D:\mysql-5.0.67-win32\bin>[color=red]net stop mysql5[/color]
MySQL5 服务正在停止..
MySQL5 服务已成功停止。

D:\mysql-5.0.67-win32\bin>[color=red]net start mysql5[/color]
MySQL5 服务正在启动 .
MySQL5 服务已经启动成功。

7、重新登陆MySQL5服务器
D:\mysql-5.0.67-win32\bin>[color=red]mysql -uroot -pxiaohui[/color]
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.67-community MySQL Community Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

四、数据库的创建与删除

1、创建数据库testdb
mysql> [color=red]create database testdb;[/color]
Query OK, 1 row affected (0.02 sec)

2、使用数据库testdb
mysql> [color=red]use testdb;[/color]
Database changed

3、删除数据库testdb
mysql> [color=red]drop database testdb;[/color]
Query OK, 0 rows affected (0.00 sec)

4、退出登陆
mysql> [color=red]exit[/color]
Bye

D:\mysql-5.0.67-win32\bin>

五、操作数据库数据的一般步骤

1、启动MySQL服务器
2、登陆数据库服务器
3、使用某个要操作的数据库
4、操作该数据库中的表,可执行增删改查各种操作。
5、退出登陆。

六、mysql5的卸载

删除服务

执行mysqld --remove MySQL5 即可
---------------------完---------------------
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值