1.下载MySQL安装包
下载地址:https://dev.mysql.com/downloads/mysql/
2.编译环境准备
yum -y install make cmake gcc gcc-c++ flex bison wget zlib zlib-devel openssl openssl-devel ncurses ncurses-devel libaio-devel libtirpc-devel patch cyrus-sasl-devel pkg-config
yum install -y tar
yum -y install bzip2
wget https://github.com/thkukuk/rpcsvc-proto/releases/download/v1.4/rpcsvc-proto-1.4.tar.gz
tar xf rpcsvc-proto-1.4.tar.gz
cd rpcsvc-proto-1.4/
./configure && make && make install
3、存放位置
软件源代码包存放位置:/www/zhou/mysql-8.0.25
源码包编译安装位置:/www/server/mysql
二、编译安装mysql- 8.0.25
1、上传源码包
boost_1_70_0.tar.gz mysql-8.0.19.tar.gz rpcsvc-proto-1.4.tar.gz
2、解决rpcsvc-proto-1.4
1)、解压
[17:05:14 root@wangzhike software]#tar -zxf rpcsvc-proto-1.4.tar.gz -C /usr/local/src/
1
2)、一步安装
[17:09:48 root@wangzhike rpcsvc-proto-1.4]#./configure && make && make install
3、解决boost_1_70_0
tar xf boost_1_70_0.tar.gz
4、创建mysql用户及组
groupadd mysql
useradd -s /sbin/nologin -M -g mysql mysql
cmake
cmake .. -DCMAKE_INSTALL_PREFIX=/www/server/mysql -DSYSCONFDIR=/www/server/mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/www/zhou/mysql-8.0.25/boost/boost_1_73_0 -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
make -j 3 && install
chown -R mysql:mysql /www/server/mysql
cat > /etc/my.cnf<<EOF
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
#datadir = ${MySQL_Data_Dir}
datadir=/www/server/data #MySQl数据库存放目录
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
thread_cache_size = 8
tmp_table_size = 16M
performance_schema_max_table_instances = 500
explicit_defaults_for_timestamp = true
#skip-networking
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
default_authentication_plugin = mysql_native_password
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
binlog_expire_logs_seconds = 864000
early-plugin-load = ""
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_data_home_dir =/www/server/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /www/server/data
innodb_buffer_pool_size = 16M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer_size = 2M
write_buffer_size = 2M
[mysqlhotcopy]
interactive-timeout
EOF
初始化
/www/server/mysql/bin/mysqld --initialize-insecure --basedir=/www/server/mysql --datadir=/www/server/data --user=mysql
添加软连接,并重启mysql服务
ln -s /www/server/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /www/server/mysql/bin/mysql /usr/bin/mysql
service mysql restart
空密码登入
# mysql -uroot
设置密码
SET PASSWORD FOR 'root'@'localhost' = '627086057';