mysql企业版安装

[TOC]

安装之前

  • 查询系统中是否安装mariadb或mysql
rpm -qa | egrep "(mariadb|mysql)"
  • 卸载系统中的mariadb或mysql
rpm -e --allmatches --nodeps mariadb-libs-*
yum -y remove mysql-libs*
  • 安装MySQL依赖包:
yum install -y gcc gcc-c++ ncurses ncurses-devel openssl openssl-devel cmake perl lsof bison

单实例安装

二进制安装 mysql-commercial-8.0.20

  • 创建用户
groupadd mysql -g 1300
useradd -M -u 1300 -g mysql -s /sbin/nologin mysql
  • 下载安装文件并解压
curl -sL http://iso.sqlfans.cn/mysql/mysql-commercial-8.0.20-linux-glibc2.12-x86_64.tar.xz -o /opt/mysql-commercial-8.0.20-linux-glibc2.12-x86_64.tar.xz
tar xf /opt/mysql-commercial-8.0.20-linux-glibc2.12-x86_64.tar.xz -C /opt/
mv /opt/mysql-commercial-8.0.20-linux-glibc2.12-x86_64 /opt/mysql
  • 创建目录并赋权
mkdir -p /data/mysql_3306/{binlog,error,iblog,slow,tmp,var}
chown -R mysql:mysql /data/mysql_3306
chown -R mysql:mysql /opt/mysql
  • 初始化数据
/opt/mysql/bin/mysqld --no-defaults --initialize --user=mysql --lower-case-table-names=0 \
--basedir=/opt/mysql/ --datadir=/data/mysql_3306/var --innodb_log_group_home_dir=/data/mysql_3306/iblog --innodb_data_home_dir=/data/mysql_3306/iblog \
--innodb_data_file_path=ibdata1:1G:autoextend --innodb_log_file_size=1342177280 --innodb_log_files_in_group=3 --innodb_undo_directory=/data/mysql_3306/iblog \
--innodb_max_undo_log_size=2G --plugin_dir=/opt/mysql/lib/plugin &> /tmp/mysqlinstall.log
  • 修改配置文件
curl -sL http://iso.sqlfans.cn/mysql/config/8.0/my_innodb_enterprise.cnf -o /data/mysql_3306/my_3306.cnf
touch /data/mysql_3306/error/mysql_run.err
chown -R mysql:mysql /data/mysql_3306
ln -sf /opt/mysql/bin/* /usr/bin/
  • 配置mysql服务
cat > /etc/systemd/system/mysqld.service <<EOF
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://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=/data/mysql_3306/my_3306.cnf
LimitNOFILE = 5000
EOF
  • 以systemctl方式启动mysql服务
systemctl enable mysqld
systemctl start mysqld 
systemctl status mysqld
  • 重置root密码
passwd=`cat /tmp/mysqlinstall.log |grep "temporary password"|tail -1|cut -d' ' -f13`
/opt/mysql/bin/mysql --connect-expired-password -uroot --socket=/tmp/mysql_3306.sock -p$passwd -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'Admin_147';"
mysql -uroot -pAdmin_147 -S /tmp/mysql_3306.sock -e "select @@version;"

[附] 重新再来

ps -ef | grep mysql | grep -v grep | awk '{print $2}' | xargs kill -9
userdel -r mysql 2> /dev/null
rm -rf /opt/mysql
rm -rf /data/mysql_*
rm -f /etc/systemd/system/mysqld.service
systemctl reset-failed mysqld
netstat -lnpt | grep mysql
Copyright © www.sqlfans.cn 2024 All Right Reserved更新时间: 2023-10-16 14:37:53

results matching ""

    No results matching ""