安装mysql 5.5.24(多实例)
安装 mysql 5.5.24 前奏,安装 cmake:
apt-get install cmake
升级安装 glibc:
apt-get install glibc
安装 mysql 5.5.24 前奏,安装 bison:
apt-get install bison
安装 mysql 5.5.24 前奏,安装 libncurses5-dev
apt-get install libncurses5-dev
mysql 5.5.24 安装前奏【结束】
——————————————————————————————————
正式安装 Mysql server 5.5.24
用源码下载编译安装
tar zxvf mysql-5.5.24.tar.gz
cd mysql-5.5.24
cmake .
make
make test
make install
cmake过程中若出错,解决错误提示中的问题后,执行rm CMakeCache.txt,然后重新从cmake那一步开始
Mysql 5.5.24 server 安装完成。
——————————————————————————————————
添加用户组和用户
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
复制配置文件
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
——————————————————————————————————
修改 mysql 安装目录和数据存放目录的所有者和权限
chown -R mysql:mysql /usr/local/mysql/
chown -R mysql:mysql /var/database/mysql/
——————————————————————————————————
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
——————————————————————————————————
初始化mysql
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/var/database/mysql --user=mysql
启动mysql
service mysqld start
这时候报错!
Starting MySQL
.. * The server quit without updating PID file (/usr/local/mysql/data/mysqld.pid).
解决办法
修改配置文件 /etc/my.cnf
在 [mysqld]下添加
user = mysql
pid-file = /usr/local/mysql/data/mysqld.pid
basedir = /usr/local/mysql
datadir = /var/database/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
重新启动mysql,成功!
——————————————————————————————————
——————————————————————————————————
设置环境变量
vi /etc/profile
加入以下内容,保存:
export PATH=/usr/local/mysql/bin:$PATH
应用安装目录:/usr/local/mysql
数据存放目录:/var/database/mysql
配置文件目录:/etc/
默认mysql启动后sock文件位置:/tmp/mysql.sock
——————————————————————————————————
多实例配置
第一步:修改配置文件:/etc/my.cnf
1.添加mysqld_multi:
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = root
2.添加各个实例配置文件
[mysqld2]
port = 3302
socket = /tmp/mysql2.sock
user = mysql
pid-file = /usr/local/mysql/data/mysqld2.pid
basedir = /usr/local/mysql
datadir = /var/database/mysql2
skip-external-locking
key_buffer_size = 128M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 32M
thread_cache_size = 8
query_cache_size = 16M
[mysqld3]
port = 3303
socket = /tmp/mysql3.sock
user = mysql
pid-file = /usr/local/mysql/data/mysqld3.pid
basedir = /usr/local/mysql
datadir = /var/database/mysql3
skip-external-locking
key_buffer_size = 128M
max_allowed_packet = 1M
table_open_cache = 512
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 32M
thread_cache_size = 8
query_cache_size = 16M
第二步:初始化各实例
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/var/database/mysql2 --user=mysql
和
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/var/database/mysql3 --user=mysql
这样在/var/database目录下会多出两个文件夹mysql2和mysql3
第三步:启动实例
mysqld_multi start 2
mysqld_multi start 3
第四步:修改实例登录密码
mysqladmin --socket=/tmp/mysql2.sock -uroot password 'yourpassword'
第五步:登录实例
mysql --socket=/tmp/mysql2.sock -pyourpassword
查看各实例的服务:
Ps -aux |grep mysqld
查看端口:
本文出自 “Linux_life” 博客,转载请与作者联系!