《MYSQL数据库CentOS6.9+Mysql5.7.18源码安装详细教程》要点:
本文介绍了MYSQL数据库CentOS6.9+Mysql5.7.18源码安装详细教程,希望对您有用。如果有疑问,可以联系我们。
MYSQL实例CentOS6.9+Mysql5.7.18源码安装,以下操作均在root用户下执行.
MYSQL实例1、安装依赖工具
MYSQL实例
cmake make3.75+ gcc4.4.6+ Boost1.59.0 bison ncurses
yum install -y cmake,make,gcc,gcc-c++,bison, ncurses,ncurses-devel
cd /opt
MYSQL实例wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
MYSQL实例或者向度娘要一个
MYSQL实例
tar -zxvf boost_1_59_0.tar.gz -C /usr/local/
MYSQL实例2、下载mysql准备安装
MYSQL实例git clone https://github.com/mysql/mysql-server.git
MYSQL实例没有git就 yum install git装一个
MYSQL实例选择5.7
MYSQL实例创建mysql用户,用户组为root
MYSQL实例
useradd -r -g root -s /bin/false mysql
MYSQL实例3、执行cmake
MYSQL实例
cd /opt/mysql-server5.7
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=/usr/local/boost_1_59_0 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DSYSCONFDIR=/etc \
-DEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all
-DCMAKE_INSTALL_PREFIX:安装路径-DMYSQL_DATADIR:数据存放目录-DWITH_BOOST:boost源码路径-DSYSCONFDIR:my.cnf配置文件目录-DEFAULT_CHARSET:数据库默认字符编码-DDEFAULT_COLLATION:默认排序规则-DENABLED_LOCAL_INFILE:允许从本文件导入数据-DEXTRA_CHARSETS:安装所有字符集 4、编译安装
make -j `grep processor /proc/cpuinfo | wc -l`
make install
-j参数表示根据CPU核数指定编译时的线程数,可以加快编译速度.
如果中途编译失败了,需要删除cmake生成的预编译配置参数的缓存文件和make编译后生成的文件,再重新编译.
cd /opt/mysql-server5.7
rm -f CMakeCache.txt
make clean
MYSQL实例5、初始化系统数据库
MYSQL实例
vim /etc/my.cnf
MYSQL实例进入insert模式,将原来内容替换成如下内容:
MYSQL实例
[client]
port=3306
socket=/temp/mysql.sock
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci
skip-external-locking
skip-name-resolve
user=mysql
port=3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
tmpdir=/usr/local/mysql/temp
# server_id = .....
socket=/usr/local/mysql/mysql.sock
log-error=/usr/local/mysql/logs/mysql_error.log
pid-file=/usr/local/mysql/mysql.pid
open_files_limit=10240
back_log=600
max_connections=500
max_connect_errors=6000
wait_timeout=605800
#open_tables=600
#table_cache = 650
#opened_tables = 630
max_allowed_packet=32M
sort_buffer_size=4M
join_buffer_size=4M
thread_cache_size=300
query_cache_type=1
query_cache_size=256M
query_cache_limit=2M
query_cache_min_res_unit=16k
tmp_table_size=256M
max_heap_table_size=256M
key_buffer_size=256M
read_buffer_size=1M
read_rnd_buffer_size=16M
bulk_insert_buffer_size=64M
lower_case_table_names=1
default-storage-engine=INNODB
innodb_buffer_pool_size=2G
innodb_log_buffer_size=32M
innodb_log_file_size=128M
innodb_flush_method=O_DIRECT
#####################
thread_concurrency=32
long_query_time=2
slow-query-log=on
slow-query-log-file=/usr/local/mysql/logs/mysql-slow.log
[mysqldump]
quick
max_allowed_packet=32M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
cd /usr/local/mysql
mkdir data
mkdir logs
mkdir temp
chmod 0770 -R .
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --socket=/tmp/mysql.sock
MYSQL实例在MySQL 5.7.6版本以前是 bin/mysql_install_db --user
MYSQL实例执行完成后,查看 logs/mysql_error.log文件,将里面的临时root暗码记下来
MYSQL实例
A temporary password is generated for root@localhost: xxxxxxxxxx
MYSQL实例6、配置mysql
MYSQL实例
chkconfig --add mysqld # 添加到系统服务
chkconfig mysqld on # 开机启动
service mysqld start启动不成功,使用safe模式启动
chown -R mysql:root /var/run/mysqld
./bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql &
./mysql -uroot -p
MYSQL实例输入mysql_error.log中的临时暗码登入mysql控制台
MYSQL实例
set password='asdfghjkl'';
Query OK, 0 rows affected (0.00 sec)
show warnings;
MYSQL实例停止mysql
MYSQL实例
mysqladmin -u root -p shutdown
MYSQL实例输入刚才设置的暗码,停止成功
MYSQL实例接下来可以使用系统服务来启动mysql了:
MYSQL实例
service mysqld start # 启动mysql服务
MYSQL实例以上所述是小编给大家介绍的CentOS6.9+Mysql5.7.18源码安装,希望对大家有所赞助,如果大家有任何疑问请给我留言,小编会及时回复大家的.在此也非常感谢大家对维易PHP网站的支持!
维易PHP培训学院每天发布《MYSQL数据库CentOS6.9+Mysql5.7.18源码安装详细教程》等实战技能,PHP、MYSQL、LINUX、APP、JS,CSS全面培养人才。