8.查看一下初始化目录
[root@node6 data]# ls /data/MySQL/
mysql mysql-bin.000001 mysql-bin.000002 mysql-bin.index test
9.启动一下mysql
[root@node6 ~]# service mysqld start
Starting MySQL.. SUCCESS!
10.测试访问一下
[root@node6 ~]# /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-log Source distribution
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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql>
好了,到这里我们的mysql基本就安装完成,但我们还提做上些优化工作。
11.输出mysql的man手册至man命令的查找路径
[root@node6 ~]# yum install -y man
[root@node6 ~]# vim /etc/man.config
MANPATH /usr/local/mysql/man
12.输出mysql的头文件至系统头文件路径/usr/include
[root@node6 mysql]# ln -sv /usr/local/mysql/include /usr/include/mysql
13.输出mysql的库文件给系统库查找路径
[root@node6 mysql]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@node6 mysql]# ldconfig
14.修改PATH环境变量,让系统可以直接使用mysql的相关命令
[root@node6 mysql]# vim /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin/
[root@node6 mysql]# source /etc/profile
[root@node6 mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73-log Source distribution
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>
好了,到这里我们的mysql就全部安装完成了,下面我们来准备一下测试环境。
15.新建测试库与测试表
mysql> CREATE DATABASE mydb;
Query OK, 1 row affected (0.33 sec)
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mydb |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> use mydb;
Database changed
mysql> show create database mydb;
+----------+---------------------------------------------------------------+
| Database | Create Database |
+----------+---------------------------------------------------------------+
| mydb | CREATE DATABASE `mydb` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+---------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show tables;
Empty set (0.01 sec)
mysql> CREATE TABLE `t1` (id int(11) DEFAULT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8 ;
Query OK, 0 rows affected (0.03 sec)
mysql> show create table t1;
+-------+--------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+--------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
`id` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 |
+-------+--------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> show tables;
+----------------+
| Tables_in_mydb |
+----------------+
| t1 |
+----------------+
1 row in set (0.00 sec)
mysql> desc t1;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
1 row in set (0.33 sec)
16.准备1000万数据
注,现在我们要测试的表是空表,下面我们要用下面的方法,快速插入1000万数据。
(1).先简单插入10行数据,
mysql> insert into t1 value (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
(2).查看一下
mysql> select * from t1;
+------+
| id |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
+------+
10 rows in set (0.00 sec)
(3).插入多行数据方法
mysql> insert into t1 select * from t1;
Query OK, 10 rows affected (0.00 sec)
Records: 10 Duplicates: 0 Warnings: 0
mysql> select count(*) from t1;
+----------+
| count(*) |
+----------+
| 20 |
+----------+
1 row in set (0.33 sec)
大家可以看到现在我们有20行数据,使用 insert into t1 select * from t1 这样的插入数据方法,数据不但可以成倍增长,而且增加的数据可控,方便我们测试100万数据、200万数据、500万数据,以及更多数据测试。下面我们就开始数据读写测试。
