时间:2021-07-01 10:21:17 帮助过:49人阅读
以下是详细的安装方法:
1,安装mysql
使用源码安装.
tar -zxvf mysql-5.5.49.tar.gz
cd mysql-5.5.49
mkdir /usr/local/mysql
cmake - -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
make
make install
2,先设置下my.cnf
cp support-files/my-medium.cnf /etc/my.cnf
chown mysql:mysql -R /usr/local/mysql/
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/dbdata/mysql/data
初始化数据库
3,设置不同的目录文件
mkdir -p /dbdata/{3307,3308,3309}/data
cp /etc/my.cnf /dbdata/3307/
cp /etc/my.cnf /dbdata/3308/
cp /etc/my.cnf /dbdata/3309/
vim /dbdata/3307/my.cnf
++++++++++++++++++
[client]
port = 3307
socket = /dbdata/3307/mysql.sock
[mysqld]
port = 3307
socket = /dbdata/3307/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
skip-name-resolve
basedir = /usr/local/mysql
datadir = /dbdata/3307/data
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
log-error=/dbdata/3307/3307.err
pid-file=/dbdata/3307/3307.pid
分别更改 3308 3309端口的配置文件
4,初始化启动
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/dbdata/3307/data --user=mysql
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/dbdata/3308/data --user=mysql
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/dbdata/3309/data --user=mysql
启动:
/usr/local/mysql/bin/mysqld_safe --defaults-file=/dbdata/3307/my.cnf &
/usr/local/mysql/bin/mysqld_safe --defaults-file=/dbdata/3308/my.cnf &
/usr/local/mysql/bin/mysqld_safe --defaults-file=/dbdata/3309/my.cnf &
登陆:
mysql -uroot -p -S /dbdata/3308/mysql.sock
更改密码
mysqladmin -uroot -p password 123456 -S /dbdata/3307/mysql.sock
完成。