Debianにmysql-serevr入れた

環境

Linux debian 2.6.32-5-amd64

パッケージリストの更新

$ apt-cache search mysql-server 

インストール

$ apt-get install mysql-server-5.1

なんか古いパッケージしか出てこない。とりあえず後回し。

インストール中、パスワードを入れろ!とこんな画面になる

ブルースクリーン風っぽくてまじびびるからやめて欲しいです。

何も入力しないでエンターでOK。

以下インストール中のログ
$ apt-get install mysql-server-5.1
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libnet-daemon-perl libplrpc-perl
  mysql-client-5.1 mysql-common mysql-server-core-5.1
Suggested packages:
  libipc-sharedcache-perl libterm-readkey-perl tinyca
The following NEW packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient16 libnet-daemon-perl libplrpc-perl
  mysql-client-5.1 mysql-common mysql-server-5.1 mysql-server-core-5.1
0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded.
Need to get 24.1 MB of archives.
After this operation, 60.9 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://security.debian.org/ squeeze/updates/main mysql-common all 5.1.66-0+squeeze1 [77.9 kB]
Get:2 http://http.us.debian.org/debian/ squeeze/main libnet-daemon-perl all 0.43-1 [46.6 kB]
Get:3 http://http.us.debian.org/debian/ squeeze/main libplrpc-perl all 0.2020-2 [36.0 kB]                            
Get:4 http://http.us.debian.org/debian/ squeeze/main libdbi-perl amd64 1.612-1 [883 kB]                              
Get:5 http://security.debian.org/ squeeze/updates/main libmysqlclient16 amd64 5.1.66-0+squeeze1 [1,974 kB]           
Get:6 http://http.us.debian.org/debian/ squeeze/main libdbd-mysql-perl amd64 4.016-1 [140 kB]                        
Get:7 http://http.us.debian.org/debian/ squeeze/main libhtml-template-perl all 2.9-2 [65.9 kB]                       
Get:8 http://security.debian.org/ squeeze/updates/main mysql-client-5.1 amd64 5.1.66-0+squeeze1 [10.1 MB]            
Get:9 http://security.debian.org/ squeeze/updates/main mysql-server-core-5.1 amd64 5.1.66-0+squeeze1 [4,141 kB]      
Get:10 http://security.debian.org/ squeeze/updates/main mysql-server-5.1 amd64 5.1.66-0+squeeze1 [6,613 kB]          
Fetched 24.1 MB in 10min 21s (38.7 kB/s)                                                                             
Preconfiguring packages ...
Selecting previously deselected package mysql-common.
(Reading database ... 43036 files and directories currently installed.)
Unpacking mysql-common (from .../mysql-common_5.1.66-0+squeeze1_all.deb) ...
Selecting previously deselected package libnet-daemon-perl.
Unpacking libnet-daemon-perl (from .../libnet-daemon-perl_0.43-1_all.deb) ...
Selecting previously deselected package libplrpc-perl.
Unpacking libplrpc-perl (from .../libplrpc-perl_0.2020-2_all.deb) ...
Selecting previously deselected package libdbi-perl.
Unpacking libdbi-perl (from .../libdbi-perl_1.612-1_amd64.deb) ...
Selecting previously deselected package libmysqlclient16.
Unpacking libmysqlclient16 (from .../libmysqlclient16_5.1.66-0+squeeze1_amd64.deb) ...
Selecting previously deselected package libdbd-mysql-perl.
Unpacking libdbd-mysql-perl (from .../libdbd-mysql-perl_4.016-1_amd64.deb) ...
Selecting previously deselected package mysql-client-5.1.
Unpacking mysql-client-5.1 (from .../mysql-client-5.1_5.1.66-0+squeeze1_amd64.deb) ...
Selecting previously deselected package mysql-server-core-5.1.
Unpacking mysql-server-core-5.1 (from .../mysql-server-core-5.1_5.1.66-0+squeeze1_amd64.deb) ...
Processing triggers for man-db ...
Setting up mysql-common (5.1.66-0+squeeze1) ...
Selecting previously deselected package mysql-server-5.1.
(Reading database ... 43414 files and directories currently installed.)
Unpacking mysql-server-5.1 (from .../mysql-server-5.1_5.1.66-0+squeeze1_amd64.deb) ...
Selecting previously deselected package libhtml-template-perl.
Unpacking libhtml-template-perl (from .../libhtml-template-perl_2.9-2_all.deb) ...
Processing triggers for man-db ...
Setting up libnet-daemon-perl (0.43-1) ...
Setting up libplrpc-perl (0.2020-2) ...
Setting up libdbi-perl (1.612-1) ...
Setting up libmysqlclient16 (5.1.66-0+squeeze1) ...
Setting up libdbd-mysql-perl (4.016-1) ...
Setting up mysql-client-5.1 (5.1.66-0+squeeze1) ...
Setting up mysql-server-core-5.1 (5.1.66-0+squeeze1) ...
Setting up mysql-server-5.1 (5.1.66-0+squeeze1) ...
Stopping MySQL database server: mysqld.

Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..
Setting up libhtml-template-perl (2.9-2) ...

確認

プロンプトが帰ってきたら

ログイン
$ mysql -u root
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql> quit

OK。

Sockの場所の確認

$ sudo mysqladmin version
mysqladmin  Ver 8.42 Distrib 5.1.66, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2012, 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.

Server version		5.1.66-0+squeeze1
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/run/mysqld/mysqld.sock
Uptime:			18 min 55 sec

Threads: 1  Questions: 330  Slow queries: 0  Opens: 287  Flush tables: 2  Open tables: 23  Queries per second avg: 0.290

ユーザ作成

mysql> GRANT ALL PRIVILEGES ON *.* TO kawagui IDENTIFIED BY '' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
作成したユーザでログインしてみる
$ mysql -u kawagui
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 54
Server version: 5.1.66-0+squeeze1 (Debian)

Copyright (c) 2000, 2012, 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> create databases apple;
Query OK, 1 row affected (0.00 sec)

データベースを選択

mysql> use apple;
Database changed

テーブル作成

mysql> CREATE TABLE t1 (col1 INT, col2 CHAR(5)) PARTITION BY HASH(col1);
PARTITION BY HASHについて

http://search.net-newbie.com/mysql51/partitioning.html
よくわからん

テーブル一覧表示

mysql> show tables;
+-----------------+
| Tables_in_apple |
+-----------------+
| t1              |
+-----------------+
1 row in set (0.00 sec)

レコード挿入

mysql> insert into t1 values(1, 'aaaaaaaaaaa');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> insert into t1 values(1, 'aaaaaaaaaaa');
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> insert into t1 values(1, 'aaaaaaaaaaa');
Query OK, 1 row affected, 1 warning (0.00 sec)

レコード表示

mysql> select * from t1
    -> ;
+------+-------+
| col1 | col2  |
+------+-------+
|    1 | aaaaa |
|    1 | aaaaa |
|    1 | aaaaa |
+------+-------+
3 rows in set (0.00 sec)

レコード変更

mysql> update t1 set col2 = 'bb' where col2 = 'aaaaa';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0
mysql> select * from t1;
+------+------+
| col1 | col2 |
+------+------+
|    1 | bb   |
|    1 | bb   |
|    1 | bb   |
+------+------+
3 rows in set (0.00 sec)

レコード削除

mysql> delete from t1;
Query OK, 3 rows affected (0.00 sec)
mysql> select * from t1;
Empty set (0.00 sec)