这篇文章主要介绍“怎么用源码安装mysql5.6.37”,在日常操作中,相信很多人在怎么用源码安装mysql5.6.37问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么用源码安装mysql5.6.37”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
MYSQL 源码安装:
修改参数文件:
vi /etc/security/limits.conf
mysql soft nproc 2047
mysql hard nproc 16384
mysql soft nofile 1024
mysql hard nofile 65536
下载5.6.37源码
解压后用cmake安装:
cmake . -DCMAKE_INSTALL_PREEIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWICH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PREFSCHEMA_STORAGE_ENGINE=1 \
-DCOMPILATION_COMMENT='JSS for mysqltest' \
-DWITH_READLINE=ON \
-DSYSCONFDIR=/data/mysqldata/3306 \
-DMYSQL_UNIX_ADDR=/data/mysqldata/3306/mysql.sock
编译称重后安装
make && make install
chown -R mysql:mysql /usr/local/mysql
export LANG=zh_CN.CB18030
export PATH=/usr/local/mysql/bin:$PATH
cd /data/
mkdir -p /data/mysqldata/{3306/{data,tmp,binlog},backup,scripts}
chown -R mysql:mysql mysqldata
su - mysql
cd /usr/local/mysql
编辑参数文件
/data/mysqldata/3306/my.cnf
[client]
port = 3306
socket = /data/mysqldata/3306/mysql.sock
#The MySQL server
[mysqld]
port =3306
user =mysql
socket =/data/mysqldata/3306/mysql.sock
pid-file=/data/mysqldata/3306/mysql.pid
basedir =/usr/local/mysql
datadir =/data/mysqldata/3306/data
tmpdir =/data/mysqldata/3306/tmp
open_files_limit =10240
explicit_defaults_for_timestamp
sql_mode =NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#Buffer
max_allowed_packet =256m
max_heap_table_size =256m
net_buffer_length =8k
sort_buffer_size =2m
join_buffer_size =4m
read_buffer_size =2m
read_rnd_buffer_size =16m
#Log
log-bin =/data/mysqldata/3306/binlog/mysql-bin
binlog_cache_size =32m
max_binlog_cache_size =512m
max_binlog_size =512m
binlog_format =mixed
log_output =FILE
log-error =../mysql-error.log
slow_query_log =1
slow_query_log_file =../slow_query.log
general_log =0
general_log_file =../general_query.log
expire-logs-days =14
#InnoDB
innodb_data_file_path =ibdata1:2048m:autoextend
innodb_log_file_size =256m
innodb_log_files_in_group =3
innodb_buffer_pool_size =1024m
[mysql]
no-auto-rehash
prompt =(\u@\h) [\d]>\_
default-character-set=gbk
初始化db
/usr/local/mysql/scripts/mysql_install_db --datadir=/data/mysqldata/3306/data --basedir=/usr/local/mysql
此处因为参数文件手敲,出现了错误,需要重新初始化,步骤为:
1 删除/usr/local/mysql/my.cnf
2 删除/data/mysqldata/3306下除了my.cnf外的所有文件,并重新创建此目录下的binlog,data,tmp目录
3 重新运行初始化脚本
启动mysql
mysqld_safe --defaults-file=/data/mysqldata/3306/my.cnf &
netstat -lnt|grep 3306
ps -ef|grep bin/mysql|grep -v grep
设置管理员用户与密码:
mysql
select user,host from mysql.user ;
delete from mysql.user where (user,host) not in (select 'root','localhost');
update mysql.user set user='system',password=password('xxxxxxxxx');
truncate table mysql.db;
flush privileges;
这样就安全了。
到此,关于“怎么用源码安装mysql5.6.37”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!