mysql5.7.44 通用独立体系 源码安装
安装依赖
apt-get install cmake libtirpc-dev libaio1 openssl developer libssl-dev pkg-config libtirpc
创建安装目录和创建用户赋权
mkdir -p /opt/mysql/data
groupadd mysql
useradd -M -s /sbin/nologin mysql -g mysql
chown mysql:mysql -R /opt/mysql/data
#####################################################
cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql \
-DMYSQL_DATADIR=/opt/mysql/data \
-DMYSQL_UNIX_ADDR=/opt/mysql/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_ZLIB=bundled \
-DWITH_SSL=system \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLE_DOWNLOADS=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/data/ym/mysql-5.7.44/boost \
-DWITH_DEBUG=0
##参数解析
#程序存放位置
cmake . -DCMAKE_INSTALL_PREFIX=/opt/mysql \
#数据存放位置
-DMYSQL_DATADIR=/opt/mysql/data \
#socket文件存放位置
-DMYSQL_UNIX_ADDR=/opt/mysql/tmp/mysql.sock \
#使用utf8字符集
-DDEFAULT_CHARSET=utf8 \
#校验规则
-DDEFAULT_COLLATION=utf8_general_ci \
#使用其他额外的字符集
-DWITH_EXTRA_CHARSETS=all \
#支持的存储引擎
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
#禁用的存储引擎
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
#启用zlib库支持(zib、gzib相关)
-DWITH_ZLIB=bundled \
#启用SSL库支持(安全套接层)
-DWITH_SSL=bundled \
#启用本地数据导入支持
-DENABLED_LOCAL_INFILE=1 \
#编译嵌入式服务器支持
-DWITH_EMBEDDED_SERVER=1 \
# mysql5.6支持了google的c++mock框架了,允许下载,否则会安装报错。
-DENABLE_DOWNLOADS=1 \
#禁用debug(默认为禁用)
-DWITH_DEBUG=0
#根据提示补足依赖
make && make install
修改相关配置文件
vim /etc/my.cnf
#[client]
#port = 3306
#socket = /opt/mysql/tmp/mysql.sock
[mysqld]
port = 3306
socket = /opt/mysql/tmp/mysql.sock
user = mysql
basedir = /opt/mysql
datadir = /opt/mysql/data
skip-external-locking
key_buffer_size = 32M
max_allowed_packet = 1024M
table_open_cache = 128
sort_buffer_size = 768K
net_buffer_length = 8K
read_buffer_size = 768K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
query_cache_size = 16M
tmp_table_size = 32M
performance_schema_max_table_instances = 1000
explicit_defaults_for_timestamp = true
#skip-networking
max_connect_errors = 100
open_files_limit = 65535
log_bin=mysql-bin
binlog_format=mixed
server_id = 232
expire_logs_days = 10
early-plugin-load = ""
default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_buffer_pool_size = 128M
innodb_log_file_size = 32M
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 = 32M
sort_buffer_size = 768K
read_buffer = 2M
write_buffer = 2M
################################################
################################################
vi /etc/systemd/system/mysql.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=https://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/opt/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
#初始化数据库,目录自定义
./mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data
################################################
#创建socket文件目录
mkdir /opt/mysql/tmp
#重启
systemctl daemon-reload && systemctl start mysql && systemctl enable mysql
#验证和修改密码和其他创建命令
mysql -uroot -p #密码为初始化日志显示密码
修改root用户密码
第一种:
MySQL > SET PASSWORD=PASSWORD('123');
Query OK, 0 rows affected (0.00 sec)
第二种:
MySQL > grant all privileges on *.* to root@'%' identified by '123';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
#创建数据库密码和用户
CREATE DATABASE xxx CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
GRANT ALL on xxx.* TO 'jira'@'%' IDENTIFIED BY 'xxxx';
flush privileges;
show databases; 查看库
use db_name; 进入库
show tables; 查看表
select * from MyClass; #查看表数据
CREATE DATABASE IF NOT EXISTS xxx DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON *.* TO 'xxx'@'%' IDENTIFIED BY 'xxx' WITH GRANT OPTION;
#关闭了密码复杂度校验```
#后续就是一些正常操作和登录
#建议官网下载
5.7.44源码包
夸克网盘链接:https://pan.quark.cn/s/2e930d7296e9
提取码:9MQE