內容提要:MySQL-noinstall-5.0.67-win32.zip的安裝教程
一、下載,這裡使用綠色解壓縮版
http://MySQL.west.mirrors.airband.Net/Downloads/MySQL-5.0/MySQL-noinstall-5.0.67-win32.zip
二、配置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
default-character-set=gbk
[MySQLd]
port = 3306
socket = /tmp/MySQL.sock
default-character-set=gbk
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>mysqld --install MySQL5 --defaults-file=D:\MySQL-5.0.67-win32\my-small.ini
Service successfully installed.
3)、啟動MySQL5服務
D:\mysql-5.0.67-win32\bin>net start MySQL5
MySQL5 服務正在啟動 .
MySQL5 服務無法啟動。
4)、登陸MySQL5服務器
D:\mysql-5.0.67-win32\bin>MySQL -uroot -p
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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MySQL |
| test |
+--------------------+
3 rows in set (0.02 sec)
可以看到MySQL服務器中有三個數據庫。
6)、使用數據庫
MySQL> use test
Database changed
7)、查看數據庫中的表
sql> show tables;
Empty set (0.00 sec)
8)、創建表ttt
MySQL> create table ttt(a int,b varchar(20));
Query OK, 0 rows affected (0.00 sec)
9)、插入三條數據
MySQL> insert into ttt values(1,'aaa');
Query OK, 1 row affected (0.02 sec)
MySQL> insert into ttt values(2,'bbb');
Query OK, 1 row affected (0.00 sec)
MySQL> insert into ttt values(3,'ccc');
Query OK, 1 row affected (0.00 sec)
10)、查詢數據
MySQL> select * from ttt;
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
| 3 | ccc |
+------+------+
3 rows in set (0.00 sec)
11)、刪除數據
MySQL> delete from ttt where a=3;
Query OK, 1 row affected (0.01 sec)
刪除後查詢操作結果:
MySQL> select * from ttt;
+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | bbb |
+------+------+
2 rows in set (0.00 sec)
12)、更新數據
MySQL> update ttt set b = 'xxx' where a =2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
查看更新結果:
MySQL> select * from ttt;+------+------+
| a | b |
+------+------+
| 1 | aaa |
| 2 | xxx |
+------+------+
2 rows in set (0.00 sec)
13)、刪除表
MySQL> drop table ttt;
Query OK, 0 rows affected (0.00 sec)
查看數據庫中剩余的表:
MySQL> show tables;
Empty set (0.00 sec)
三、更改MySQL5數據庫root用戶的密碼
1、使用MySQL數據庫
mysql> use MySQL
Database changed
2、查看MySQL數據庫中所有的表
MySQL> show tables;
+---------------------------+
| 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> delete from user;
Query OK, 3 rows affected (0.00 sec)
4、創建一個root用戶,密碼為“xiaohui”。
MySQL> grant all on *.* to root@'%' identifIEd by 'xiaohui' with grant option;
Query OK, 0 rows affected (0.02 sec)
5、查看user表中的用戶
MySQL> select User from user;
+------+
| User |
+------+
| root |
+------+
1 row in set (0.00 sec)
6、重啟MySQL5:更改了MySQL用戶後,需要重啟MySQL服務器才可以生效。
D:\mysql-5.0.67-win32\bin>net stop MySQL5
MySQL5 服務正在停止..
MySQL5 服務已成功停止。
D:\mysql-5.0.67-win32\bin>net start MySQL5
MySQL5 服務正在啟動 .
MySQL5 服務已經啟動成功。
7、重新登陸MySQL5服務器
D:\mysql-5.0.67-win32\bin>MySQL -uroot -pxiaohui
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> create database testdb;
Query OK, 1 row affected (0.02 sec)
2、使用數據庫testdb
MySQL> use testdb;
Database changed
3、刪除數據庫testdb
MySQL> drop database testdb;
Query OK, 0 rows affected (0.00 sec)
4、退出登陸
MySQL> exit
Bye
D:\MySQL-5.0.67-win32\bin>
五、操作數據庫數據的一般步驟
1、啟動MySQL服務器
2、登陸數據庫服務器
3、使用某個要操作的數據庫
4、操作該數據庫中的表,可執行增刪改查各種操作。
5、退出登陸。
六、MySQL5的卸載
刪除服務
執行mysqld --remove MySQL5 即可
---------------------完---------------------
-