mysqld --defaults-file=/home/mysql/mysql170200/my.cnf --initialize-insecure --user=mysql
#!/bin/bash
yum install -y perl perl-Module-Build net-tools autoconf libaio numactl-libs
tar -xvf mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz -C /usr/local/
cd /usr/local
ln -s mysql-8.0.28-linux-glibc2.17-x86_64-minimal/ mysql
mkdir -p /data/mysql/data
mkdir -p /data/mysql/logs
cat > /data/mysql/my.cnf <<EOF
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
user=mysql
log_error=/tmp/mysql.log
skip_name_resolve
log_bin=/data/mysql/logs/mysql-bin
port=3306
server_id=8006
EOF
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=/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/my.cnf
LimitNOFILE = 5000
EOF
useradd -s /sbin/nologin mysql
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /data/mysql
/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
echo "export PATH=/usr/local/mysql/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile
systemctl start mysqld
systemctl status mysqld
sleep 3s
/usr/local/mysql/bin/mysql -e "alter user root@'localhost' identified by 'A_dminjs#888'"
|