Ubuntu 二进制安装mysql 5.7

释放双眼,带上耳机,听听看~!
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
mkdir -p /data/mysql/3306
curl -O -q https://d.frps.cn/file/tools/mysql/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
tar zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz  -C /usr/local/
cd /usr/local
ln -s mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz  mysql
cd mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/3306 # 初始化后会返回一个临时密码
bin/mysql_ssl_rsa_setup --datadir=/data/mysql/3306
cp support-files/mysql.server /etc/init.d/mysqld

设置数据库my.cnf配置文件

cat > /etc/my.cnf << EOF
[client]
port=3306
socket=/data/mysql/3306/mysql.sock
default-character-set=utf8mb4
[mysqld]
lower_case_table_names = 1
max_allowed_packet = 64M
max_connections=4000
open_files_limit = 10000
innodb_log_file_size=640M
innodb_log_buffer_size=256M
#mysql group_concat_max_len = 102400
sql_mode='STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
####################binlog#########################
server-id=1
binlog_format=mixed
max_binlog_size=1024M
binlog_cache_size=1M
expire-logs-days=5
log_bin_trust_function_creators = on
datadir=/data/mysql/3306
socket=/data/mysql/3306/mysql.sock
pid-file=/data/mysql/3306/mysqld.pid
log-error=/data/mysql/3306/mysqld.log
default-time_zone = '+8:00'
default-storage-engine = innodb
innodb_file_per_table
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect=‘SET NAMES utf8mb4‘
log-bin=mysql-bin
expire_logs_days=30
symbolic-links=0
EOF

启动mysql

systemctl daemon-reload
/etc/init.d/mysqld start
echo "export PATH=/usr/local/mysql/bin:$PATH" >> /etc/profile
source /etc/profile

# 重置root密码
mysql -uroot -p临时密码
> alter user 'root'@'localhost' identified by 'kTFWFMPTrX65';
# 添加 puser 数据库用户
> create user 'puser'@'%' identified by 'kTFWFMPTrX65';
> grant all privileges on *.* to 'puser'@'%' identified by "kTFWFMPTrX65";

设置快速登录数据库脚本

[root@test-151 ~]# cat /usr/bin/myin
#!/bin/sh
user=root
password=kTFWFMPTrX65
#mysql -u$user -p$password -h127.0.0.1 -A -P$1 --prompt="\\u@\\p \\d> "
mysql -u$user -p$password -h127.0.0.1  -P$1

给TA买糖
共{{data.count}}人
人已赞赏
MySQL

MySQL 5.6 基于GTID 进行主从复制

2017-10-11 17:24:38

clickhouseUbuntu

Ubuntu 手动下载安装ClickHouse

2022-8-19 18:00:03

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索