原始碼安裝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;
這樣就安全了。
以上是mysql使用原始碼安裝和配置root使用者的全過程
修改引數檔案:
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;
這樣就安全了。
以上是mysql使用原始碼安裝和配置root使用者的全過程
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2145098/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- LAMP原始碼安裝+wordpress安裝LAMP原始碼
- nginx原始碼安裝Nginx原始碼
- 原始碼安裝postgresql原始碼SQL
- 原始碼安裝openresty原始碼REST
- 原始碼安裝GO原始碼Go
- Nginx 原始碼安裝Nginx原始碼
- mysql原始碼安裝MySql原始碼
- zabbix原始碼安裝原始碼
- 原始碼安裝lamp原始碼LAMP
- 原始碼安裝MySQL原始碼MySql
- 原始碼安裝Nginx原始碼Nginx
- 【推薦 - 原始碼安裝】nginx - 安裝原始碼Nginx
- yum安裝與原始碼安裝比較原始碼
- MySQL 5.7.28 原始碼安裝MySql原始碼
- docker原始碼安裝NginxDocker原始碼Nginx
- macbook 原始碼安裝 redisMac原始碼Redis
- macbook 原始碼安裝 nginxMac原始碼Nginx
- Centos原始碼安裝NginxCentOS原始碼Nginx
- Redis 4.0原始碼安裝Redis原始碼
- mysql 5.1原始碼安裝MySql原始碼
- mysql-原始碼安裝MySql原始碼
- 原始碼安裝python原始碼Python
- MYSQL 5.6.27原始碼安裝MySql原始碼
- PostgreSQL 10.12 安裝系列 - 原始碼安裝SQL原始碼
- Mysql for Linux安裝配置之—— 原始碼安裝MySqlLinux原始碼
- 連網安裝mysql與原始碼安裝mysqlMySql原始碼
- PostgreSQL-原始碼安裝(一)SQL原始碼
- 原始碼安裝Nginx和PHP原始碼NginxPHP
- 原始碼包安裝過程原始碼
- 原始碼安裝PHP的坑原始碼PHP
- paramiko 2.4.1原始碼安裝原始碼
- 原始碼編譯安裝Redis原始碼編譯Redis
- EOS原始碼分析(1)安裝原始碼
- LAMP原始碼編譯安裝LAMP原始碼編譯
- 安裝mysql原始碼出錯MySql原始碼
- MySQL 5.6.26原始碼安裝MySql原始碼
- Percona XtraBackup 原始碼安裝原始碼
- LNMP 原始碼安裝搭建薦LNMP原始碼