linux mysql 二进制安装总结

时间:2020-12-10 21:07:04

安装数据库有两种方法。第一种是源码安装,第二种是二进制安装。源码安装比较容易。在尝试二进制安装后,碰到一些事记录下来

yum 安装:

查看yum下可以安装mysql的版本:

yum list | grep mysql

发现版本是5.1.X版本,可以修改配置,使用yum安装mysql最新版本。


在安装过程中,想安装指定的版本,所以不能使用yum安装了。

二进制安装:

1、下载指定版本的二进制文件,下载地址:http://downloads.mysql.com/archives/community/。可以选择任何版本。我选择的是5.6.29

2、解压下载的mysql-5.6.29-linux-glibc2.5-i686.tar.gz文件,复制文件到/usr/local:cp mysql-5.6.29 /usr/local/mysql

3、增加mysql组和用户:

groupadd mysql

#为组增加mysql用户
 useradd -r -g mysql -s /bin/false mysql

chown -R mysql /usr/local/mysql

chgrp -R mysql /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db --user=mysql

4、创建配置文件 my.ini

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES


[client]
#password = your_password
port = 3306
socket = /data/mysql/database/mysql.sock


# The MySQL server
[mysqld]
port = 3306
socket = /data/mysql/database/mysql.sock
datadir = /data/mysql/database/
pid-file = /data/mysql/database/mysql.pid
basedir =/usr/local/mysql/


server-id = 1
log-bin=/data/mysql_backup/binlogs/database
binlog_format = MIXED
max_binlog_size = 512M
expire_logs_days = 3
long_query_time = 2
slow-query-log-file = slow.log
log-queries-not-using-indexes
event_scheduler=1
wait_timeout=315360000
interactive_timeout=31536000
connect_timeout=60
max_connect_errors=100000000
max_connections=50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer_size = 128M
write_buffer_size = 128M

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer_size = 128M
write_buffer_size = 128M

[mysqlhotcopy]
interactive-timeout
5、使用/usr/local/mysql/bin/mysqld_safe启动

/usr/local/mysql/bin/mysqld_safe --default-file=my.ini &

6、可以将mysql作为linux的service

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

cp my.ini /etc/my.ini做全局配置文件

这样便可以使用service mysql start或者service mysql stop