RHEL6系列下安装Mysql5.6
mysql-5.6.16.tar.gz源码包下载:
http://down.51cto.com/data/1875835
[root@rhel64 ~]# yum -y install gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel make cmake
tar -xzvf mysql-5.6.16.tar.gz #解压缩文件
tar -czvf mysql-5.6.16.tar.gz #压缩文件
[root@rhel64 ~]#groupadd mysql
[root@rhel64 ~]#useradd -r -g mysql mysql
[root@rhel64 ~]# tar -xzvf mysql-5.6.16.tar.gz
[root@rhel64 ~]# cd mysql-5.6.16
[root@rhel64 mysql-5.6.16]# cmake .
[root@rhel64 mysql-5.6.16]# make && make install
[root@rhel64 mysql-5.6.16]# chown -R mysql.mysql /usr/local/mysql
[root@rhel64 mysql-5.6.16]# cd /usr/local/mysql/scripts/
[root@rhel64 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
[root@rhel64 scripts]# cd /usr/local/mysql/support-files/
[root@rhel64 support-files]# cp mysql.server /etc/rc.d/init.d/mysql
[root@rhel64 support-files]# cp my-default.cnf /etc/my.cnf
[root@rhel64 support-files]# chkconfig --add mysql
[root@rhel64 support-files]# chkconfig mysql on
[root@rhel64 support-files]# service mysql start
Starting MySQL... [ OK ]
[root@rhel64 support-files]# ln -s /usr/local/mysql/bin/* /usr/bin/
[root@rhel64 support-files]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.16 Source distribution
Copyright (c) 2000, 2014, 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> status;
--------------
mysql Ver 14.14 Distrib 5.6.16, for Linux (x86_64) using EditLine wrapper
Connection id:1
Current database:
Current user:root@localhost
SSL:Not in use
Current pager:stdout
Using outfile:‘‘
Using delimiter:;
Server version:5.6.16 Source distribution
Protocol version:10
Connection:Localhost via UNIX socket
Server characterset:latin1
Db characterset:latin1
Client characterset:utf8
Conn. characterset:utf8
UNIX socket:/tmp/mysql.sock
Uptime:1 min 34 sec
Threads: 1 Questions: 5 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.053
--------------
mysql>
创建Oracle数据库中SCOTT用户的测试表:
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show database;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘database‘ at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
mysql> CREATE TABLE dept
-> (
-> deptno INT PRIMARY KEY,
-> dname VARCHAR(14),
-> loc VARCHAR(13)
-> );
Query OK, 0 rows affected (0.04 sec)
mysql> CREATE TABLE emp
-> (
-> EMPNO INT(4) PRIMARY KEY,
-> ENAME VARCHAR(10),
-> JOB VARCHAR(10),
-> MGR INT(4),
-> HIREDATE DATE,
-> SAL DOUBLE,
-> COMM DOUBLE,
-> deptno INT,
-> FOREIGN KEY (deptno) REFERENCES dept(deptno));
Query OK, 0 rows affected (0.02 sec)
mysql> CREATE TABLE salgrade
-> (grade INT PRIMARY KEY,
-> losal INT,
-> hisal INT);
Query OK, 0 rows affected (0.02 sec)
mysql>
插入测试数据:
mysql> INSERT INTO dept VALUES
-> (10,‘ACCOUNTING‘,‘NEW YORK‘);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO dept VALUES
-> (20,‘RESEARCH‘,‘DALLAS‘);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO dept VALUES
-> (30,‘SALES‘,‘CHICAGO‘);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO dept VALUES
-> (40,‘OPERATIONS‘,‘BOSTON‘);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> INSERT INTO emp VALUES
-> (7369,‘SMITH‘,‘CLERK‘,7902,DATE(‘1980-12-17‘),800,NULL,20);
RT INTO emp VALUES
(7566,‘JONES‘,‘MANAGER‘,7839,DATE(‘1981-4-2‘),2975,NULL,20);
INSERT INTO emp VALUES
(7654,‘MARTIN‘,‘SALESMAN‘,7698,DATE(‘1981-9-28‘),1250,1400,30);
INSERT INTO emp VALUES
(7698,‘BLAKE‘,‘MANAGER‘,7839,DATE(‘1981-5-1‘),2850,NULL,30);
INSERQuery OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7499,‘ALLEN‘,‘SALESMAN‘,7698,DATE(‘1981-2-20‘),1600,300,30);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO emp VALUES
-> (7521,‘WARD‘,‘SALESMAN‘,7698,DATE(‘1981-2-22‘),1250,500,30);
T INTO emp VALUES
(7844,‘TURNER‘,‘SALESMAN‘,7698,DATE(‘1981-9-8‘),1500,0,30);
INSERT INTO emp VALUES
(7876,‘ADAMS‘,‘CLERK‘,7788,DATE(‘1987-5-23‘),1100,NULL,20);
INSERT INTO emp VALUES
(7900,‘JAMES‘,‘CLERK‘,7698,DATE(‘1981-12-3‘),950,NULL,30);
INSERT INTO eQuery OK, 1 row affected (0.01 sec)
mysql> INSERT INTO emp VALUES
-> (7566,‘JONES‘,‘MANAGER‘,7839,DATE(‘1981-4-2‘),2975,NULL,20);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7654,‘MARTIN‘,‘SALESMAN‘,7698,DATE(‘1981-9-28‘),1250,1400,30);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7698,‘BLAKE‘,‘MANAGER‘,7839,DATE(‘1981-5-1‘),2850,NULL,30);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7782,‘CLARK‘,‘MANAGER‘,7839,DATE(‘1981-6-9‘),2450,NULL,10);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7788,‘SCOTT‘,‘ANALYST‘,7566,DATE(‘1987-4-19‘),3000,NULL,20);
mp VALUES
(7902,‘FORD‘,‘ANALYST‘,7566,DATE(‘1981-12-3‘),3000,NULL,20);
INSERT INTO emp VALUES
(7934,‘MILLER‘,‘CLERK‘,7782,DATE(‘1982-1-23‘),1300,NULL,10);Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7839,‘KING‘,‘PRESIDENT‘,NULL,DATE(‘1981-11-17‘),5000,NULL,10);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7844,‘TURNER‘,‘SALESMAN‘,7698,DATE(‘1981-9-8‘),1500,0,30);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7876,‘ADAMS‘,‘CLERK‘,7788,DATE(‘1987-5-23‘),1100,NULL,20);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7900,‘JAMES‘,‘CLERK‘,7698,DATE(‘1981-12-3‘),950,NULL,30);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO emp VALUES
-> (7902,‘FORD‘,‘ANALYST‘,7566,DATE(‘1981-12-3‘),3000,NULL,20);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO emp VALUES
-> (7934,‘MILLER‘,‘CLERK‘,7782,DATE(‘1982-1-23‘),1300,NULL,10);
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> INSERT INTO salgrade VALUES(1,700,1200);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO salgrade VALUES(2,1201,1400);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO salgrade VALUES(3,1401,2000);
Query OK, 1 row affected (0.02 sec)
mysql> INSERT INTO salgrade VALUES(4,2001,3000);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO salgrade VALUES(5,3001,9999);
Query OK, 1 row affected (0.00 sec)
mysql>
[1]脚本参考:
如何在Mysql数据库中创建Oracle数据库scott的几张表格
本文出自 “xbc's homepage” 博客,请务必保留此出处http://alipay.blog.51cto.com/7119970/1570454
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。