Centos 源码安装安装Mysql

mysql 专栏收录该内容
9 篇文章 0 订阅

源码下载

传送门
源码下载

安装cmake(mysql5.5以后是通过cmake来编译的)

yum install -y cmake

前置条件

tar -zxvf mysql-5.7.20.tar
cd mysql-5.7.20
useradd mysql
vim /etc/passwd
#mysql:x:1000:1000::/home/mysql:/sbin/nologin
mkdir -p /data/db/mysql/
mkdir -p /usr/local/mysql/

config

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT='MySQL Bright Thought' -DWITH_READLINE=ON -DWITH_BOOST=/usr/src/mysql-5.7.20/boost -DSYSCONFDIR=/data/db/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock

CURSES_LIBRARY 错误

Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

安装ncurses-devel

rm -rf CMakeCache.txt 
yum install -y ncurses-devel

继续config

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT='MySQL Bright Thought' -DWITH_READLINE=ON -DWITH_BOOST=/usr/src/mysql-5.7.20/boost -DSYSCONFDIR=/data/db/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock

安装

make -j8
make install

配置

vim /etc/my.cnf
[client]
port            = 3306
socket          = /tmp/mysql.sock

[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
log_timestamps = 1
port            = 3306
socket          = /tmp/mysql.sock

skip-external-locking
skip-name-resolve
datadir = /data/db/mysql
innodb_file_per_table

wait_timeout = 60
back_log = 50
max_connections = 1000
max_connect_errors = 10000

table_open_cache = 1024

max_allowed_packet = 8M
binlog_cache_size = 1M
max_heap_table_size = 128M
sort_buffer_size = 8M
join_buffer_size = 256K

thread_cache_size = 256

query_cache_size = 64M
query_cache_limit = 2M
ft_min_word_len = 4


default-storage-engine = InnoDB
thread_stack = 192K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M

log-bin=mysql-bin
binlog_format=mixed
slow_query_log
long_query_time = 5

server-id = 2

max_heap_table_size = 32M
read_buffer_size = 128K
read_rnd_buffer_size = 8M
bulk_insert_buffer_size = 32M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

innodb_buffer_pool_size = 16G
innodb_data_file_path = ibdata1:10M:autoextend
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_thread_concurrency = 16
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120


#slave_skip_errors = 1032,1062,1064
#skip_name_resolve
#slave_parallel_type = LOGICAL_CLOCK
#slave_parallel_workers = 8

[mysqldump]
quick
max_allowed_packet = 8M

[mysql]
no-auto-rehash

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 4M
write_buffer = 4M

[mysqlhotcopy]
interactive-timeout

[mysqld_safe]
open-files-limit = 8192

初始化

cd /usr/local/mysql/bin/
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/db/mysql
./mysql_ssl_rsa_setup 

添加systemV控制脚本

cp -rf /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld 

启动

/etc/init.d/mysqld start
#2019-03-26T16:49:43.776153+08:00 1 [Note] A temporary password is generated for root@localhost: d1*t4+7gq(%R

尝试链接

/usr/local/mysql/bin/mysql -uroot -p'd1*t4+7gq(%R'

修改密码

/usr/local/mysql/bin/mysqladmin -uroot -p'd1*t4+7gq(%R' password 'yourpwd'

尝试链接

/usr/local/mysql/bin/mysql -uroot -p'yourpwd'

添加系统路径环境变量

vim /etc/profile
#PATH=$PATH:/usr/local/mysql/bin
. /etc/profile
  • 1
    点赞
  • 0
    评论
  • 1
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值