MYSQL版本:MYSQL-5.5.37
操作系统:Ubuntu 12.04.5 LTS \n \l
安装步骤:
-
第一个MYSQL安装路径/usr/local/mysql 监听3306端口
启动文件/etc/init.d/mysql
-
第二个MYSQL安装路径/data/mysql 监听3307端口
启动文件/etc/init.d/mysql2
1、安装第一个MYSQL在/usr/local/mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
Setup 1: #wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz #tar -zxvf cmake-2.8.12.2.tar.gz #cd cmake-2.8.12.2 #./bootstrap #./configure #make && make install 系统如果是CENTOS,刚要安装另一个组件 #wget http://invisible-island.net/datafiles/release/ncurses.tar.gz #./configure #make && make install Setup 2: 安装MYSQL 5.5.37 #wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.37.tar.gz tar -zxvf mysql-5.5.37. tar .gz
#cd mysql-5.5.37 #cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EMBEDDED_SERVER=1 -DWITH_SSL=system #make && make install 慢长的等待过后终于完成了 #groupadd mysql #useradd -g mysql mysql #cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf #vim /etc/my.cnf #需要加入basedir,和datadir否则会出问题 [mysqld] basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
#/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data & #chown -R mysql /usr/local/mysql/data #chgrp -R mysql /usr/local/mysql/. #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql #chmod 755 /etc/init.d/mysql #chkconfig --level 345 mysql on #echo “/usr/local/mysql/lib/mysql” >> /etc/ld.so.conf #echo “/usr/local/lib” >>/etc/ld.so.conf #ldconfig #/etc/init.d/mysql start #/usr/local/mysql/bin/mysqladmin -u root password broadengate Empire CMS,phome.net #/etc/init.d/mysql restart #/etc/init.d/mysql stop OK终于完成~ |
2、安装第二个:(基本和第一个一样,注意路径和权限)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#tar -zxvf mysql-5.5.37.tar.gz #cd mysql-5.5.37 #cmake -DCMAKE_INSTALL_PREFIX=/data/mysql -DMYSQL_DATADIR=/data/mysql/data -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock -DMYSQL_TCP_PORT=3307 -DWITH_DEBUG=0 -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 #make && make install #cp /data/mysql/support-files/my-medium.cnf /data/mysql/my.cnf #vim /data/mysql/my.cnf #需要加入basedir,和datadir否则会出问题 [mysqld] basedir = /data/mysql
datadir = /data/mysql/data
#/data/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/mysql --datadir=/data/mysql/data & #chown -R mysql /data/mysql/data #chgrp -R mysql /data/mysql/. #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql2 #chmod 755 /etc/init.d/mysql2 |
好了,下面才是重点
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#vi /etc/init.d/mysql2 1)找到以下文件进行添加 basedir= /data/mysql
datadir= /data/mysql/data
conf= /data/mysql/my .cnf
2)修改以下参数 把$bindir /mysqld_safe --datadir=$datadir --pid- file =$server_pid_file $other_args > /dev/null 2>&1&替换为:
$bindir /mysqld_safe --defaults- file = /data/mysql/my .cnf --datadir=$datadir --pid- file =$server_pid_file $other_args > /dev/null 2>&1 &
3)把下面这句注释掉(前面加个 #):
parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` 4).保存退出并添加服务: chkconfig --add /etc/init .d /mysql2
|
分别启动两个MYSQL
1
2
3
|
# /etc/init.d/mysql start # /etc/init.d/mysql2 start |
查看下进程
1
2
3
4
5
|
user@ubuntu: /usr/local/mysql $ ps -ef| grep mysql
root 23328 1 0 Apr17 ? 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir= /usr/local/mysql/data --pid- file = /usr/local/mysql/data/ubuntu .pid
mysql 23616 23328 0 Apr17 ? 00:00:54 /usr/local/mysql/bin/mysqld --basedir= /usr/local/mysql --datadir= /usr/local/mysql/data --plugin- dir = /usr/local/mysql/lib/plugin --user=mysql --log-error= /usr/local/mysql/data/ubuntu .err --pid- file = /usr/local/mysql/data/ubuntu .pid --socket= /tmp/mysql .sock --port=3306
root 23777 1 0 Apr17 ? 00:00:00 /bin/sh mysql /bin/mysqld_safe --defaults- file = /data/my .cnf --user=mysql
mysql 24915 23777 0 Apr18 ? 00:00:38 /data/mysql/bin/mysqld --defaults- file = /data/my .cnf --basedir= /data/mysql --datadir= /data/mysql/data --plugin- dir = /data/mysql/lib/plugin --user=mysql --log-error= /data/mysql/data/ubuntu .err --pid- file = /data/mysql/data/ubuntu .pid --socket= /data/mysql/mysqld .
|
查看端口
1
2
3
4
5
6
7
|
user@ubuntu: /usr/local/mysql $ netstat -nalp| grep '3306'
(No info could be read for "-p" : geteuid()=1000 but you should be root.)
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN - tcp 0 0 192.168.1.119:3306 192.168.1.150:41410 ESTABLISHED - user@ubuntu: /usr/local/mysql $ netstat -nalp| grep '3307'
(No info could be read for "-p" : geteuid()=1000 but you should be root.)
tcp 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN |
可以看出两个MYSQL正常运行
登陆
所不同的是,我们在第二个MYSQL登陆时要加上sock可以进入,否则默认是第一个数据库
1
|
mysql -uroot -p --socket= /data/mysql/mysql .sock
|
本文转自 jackjiaxiong 51CTO博客,原文链接:http://blog.51cto.com/xiangcun168/1663165