1.下載mysql-noinstall-5.1.50-win32.zip,解壓到E盤(E:\mysql-5.1.50-win32)。
2.複製my-huge.ini爲my.ini。
3.修改my.ini,在[client]、[mysqld]、[mysql]後面加default-character-set = utf8,在[mysqld]下加,basedir、datadir。
[client]
default-character-set = utf8
[mysqld]
default-character-set = utf8
default-collation=utf8_bin
init_connect='SET NAMES utf8'
basedir=D:\mysql\
datadir=D:\mysql\data\
[mysql]
default-character-set=utf8
4.安裝mysql服務。(移除mysql服務mysqld --remove)
命令行下進入E:\mysql-5.1.50-win32\bin,運行mysqld --install mysql --defaults-file="E:\mysql-5.1.50-win32\my.ini"。
E:\mysql-5.1.50-win32\bin>mysqld --install mysql --defaults-file="E:\mysql-5.1.50-win32\my.ini"
Service successfully installed.
注:要加參數安裝,否則mysql administrator啓動時將提示:
Either the server service or the configuration file could not be found.Startup variable and service section are there for disabled.
進入後提示:
This section is only avaliable when connected to localhost
5.啓動mysql服務.(中止mysql服務net stop mysql)
E:\mysql-5.1.50-win32\bin>net start mysql
mysql 服務正在啓動 .
mysql 服務已經啓動成功。
6.進入mysql,並給MYSQL的root用戶加密碼。
E:\mysql-5.1.50-win32\bin>mysql -uroot -p
Enter password:
此時密碼爲空,提示輸入密碼,直接回車。
E:\mysql-5.1.50-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.1.39-community-log MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
#顯示全部數據庫
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.02 sec)
mysql> use mysql;
#切換進mysql數據庫
Database changed
mysql> show tables
;#顯示mysql數據庫中全部表。
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| host |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
| user_info |
+---------------------------+
24 rows in set (0.09 sec)
mysql>
#更新mysql數據庫中,user表中的root用戶密碼爲wheat;
mysql> update user set password=PASSWORD("wheat") where User='root';
Query OK, 0 rows affected (0.06 sec)
Rows matched: 2 Changed: 0 Warnings: 0
mysql> flush privileges
;#更新MySQL的權限表,使剛纔的密碼更改生效.也能夠重啓mysql服務.
Query OK, 0 rows affected (0.02 sec)
mysql> exit;#退出 Bye