Rumah > pangkalan data > tutorial mysql > CentOS7上编译安装MySQL5.6.23_MySQL

CentOS7上编译安装MySQL5.6.23_MySQL

WBOY
Lepaskan: 2016-06-01 13:01:38
asal
1217 orang telah melayarinya

1.下载源码

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz
Salin selepas log masuk

2.解压

tar zxvf mysql-5.6.23.tar.gz
Salin selepas log masuk


3.安装必要的包

sudo yum install cmake gcc-c++ ncurses-devel perl-Data-Dumper
Salin selepas log masuk

4.进入mysql源码目录,生成makefile

cmake .
Salin selepas log masuk

5.编译

make
Salin selepas log masuk

6.安装

sudo make install
Salin selepas log masuk
mysql将会安装到/usr/local/mysql路径。

7.添加mysql用户和组

sudo groupadd mysql
sudo useradd -r -g mysql mysql
Salin selepas log masuk

8.修改目录和文件权限,安装默认数据库

cd /usr/local/mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
sudo scripts/mysql_install_db --user=mysql
Salin selepas log masuk
sudo chown -R root .
Salin selepas log masuk
sudo chown -R mysql data
Salin selepas log masuk

至此,mysql就可以启动运行了。

9.启动mysql

CentOS7自带MariaDB的支持,/etc下默认存在my.cnf文件干扰mysql运行,需要先删掉

cd /etc
sudo rm -fr my.cnf my.cnf.d
Salin selepas log masuk

然后再/etc下重建my.cnf文件,内容如下

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = /data/mysql/data
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

max_connection = 10000
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

#binary log 
log-bin = mysql-bin
binlog_format = mixed
expire_logs_day = 30

#slow query log 
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 3
log-queries-not-using-indexes
log-slow-admin-statements
Salin selepas log masuk

现在可以启动mysql了

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
Salin selepas log masuk

CentOS7 不能使用service控制mysql服务,而源码安装的mysql也没有提供Systemd的控制脚本。

于是编辑/etc/rc.d/rc.local文件,添加mysql的开机启动命令。

/usr/local/mysql/bin/mysqld_safe --user=mysql &
Salin selepas log masuk
然后给/etc/rc.d/rc.local添加可执行权限

sudo chmod a+x /etc/rc.d/rc.local
Salin selepas log masuk

9.修改root密码

/usr/loca/mysql/bin/mysql -uroot
use mysql;
UPDATE user SET password = PASSWORD('test2015') WHERE user = 'root';
Salin selepas log masuk
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'stcm2015';
Salin selepas log masuk
FLUSH PRIVILEGES;
Salin selepas log masuk

至此,安装基本完成了,一个mysql就能用了。



Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan