CentOS6.9+Mysql5.7.18源码安装详细教程
程序员文章站
2022-11-24 18:29:46
centos6.9+mysql5.7.18源码安装,以下操作均在root用户下执行。
1、安装依赖工具
cmake make3.75+ gcc4.4.6+ bo...
centos6.9+mysql5.7.18源码安装,以下操作均在root用户下执行。
1、安装依赖工具
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
wget
或者向度娘要一个
tar -zxvf boost_1_59_0.tar.gz -c /usr/local/
2、下载mysql准备安装
git clone
没有git就 yum install git装一个
选择5.7
创建mysql用户,用户组为root
useradd -r -g root -s /bin/false mysql
3、执行cmake
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
5、初始化系统数据库
vim /etc/my.cnf
进入insert模式,将原来内容替换成如下内容:
[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 5.7.6版本以前是 bin/mysql_install_db --user
执行完成后,查看 logs/mysql_error.log文件,将里面的临时root密码记下来
a temporary password is generated for root@localhost: xxxxxxxxxx
6、配置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_error.log中的临时密码登入mysql控制台
set password='asdfghjkl''; query ok, 0 rows affected (0.00 sec) show warnings;
停止mysql
mysqladmin -u root -p shutdown
输入刚才设置的密码,停止成功
接下来可以使用系统服务来启动mysql了:
service mysqld start # 启动mysql服务
以上所述是小编给大家介绍的centos6.9+mysql5.7.18源码安装,希望对大家有所帮助
上一篇: OPPO CEO陈明永:OPPO骁龙855新机很快就会推出
下一篇: 今年的福字该怎么扫?看完秒懂