时间:2021-07-01 10:21:17 帮助过:41人阅读
rpm -qa|grep mariadb yum remove mariadb-libs -y rm -rf /etc/my.cnf
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz yum install -y libaio-devel
tar zxf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz -C /opt/ mv /opt/mysql-5.7.28-linux-glibc2.12-x86_64 /opt/mysql-5.7.28
ln -s /opt/mysql-5.7.28 /opt/mysql
echo 'export PATH=$PATH:/opt/mysql/bin' >>/etc/profile source /etc/profile mysql -V
ccat> /etc/my.cnf <<EOF [mysqld] port=3306 user=mysql basedir=/opt/mysql datadir=/data/mysql_3306 socket=/tmp/mysql_3306.sock [mysql] socket=/tmp/mysql_3306.sock EOF
mkdir -p /data/mysql_3306
useradd -s /sbin/nologin -M mysql
chown -R mysql:mysql /data/ chown -R mysql:mysql /opt/mysql*
mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql --datadir=/data/mysql_3306/
cp /opt/mysql/support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld systemctl start mysqld
netstat -lntup|grep 3306 mysql
mkdir -p /data/mysql_330{7,8} chown -R mysql:mysql /data/mysql_330*
mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql --datadir=/data/mysql_3307/ mysqld --initialize-insecure --user=mysql --basedir=/opt/mysql --datadir=/data/mysql_3308/
cat >/data/mysql_3307/my.cnf <<EOF [mysqld] port=3307 user=mysql basedir=/opt/mysql datadir=/data/mysql_3307 socket=/tmp/mysql_3307.sock [mysql] socket=/tmp/mysql_3307.sock EOF cat >/data/mysql_3308/my.cnf <<EOF [mysqld] port=3308 user=mysql basedir=/opt/mysql datadir=/data/mysql_3308 socket=/tmp/mysql_3308.sock [mysql] socket=/tmp/mysql_3308.sock EOF
cat >/etc/systemd/system/mysqld_3307.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_3307/my.cnf LimitNOFILE = 5000 EOF cat >/etc/systemd/system/mysqld_3308.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_3308/my.cnf LimitNOFILE = 5000 EOF
systemctl daemon-reload systemctl start mysqld_3307.service mysqld_3308.service
netstat -lntup|grep 330*
mysqladmin password -S /tmp/mysql_3307.sock mysqladmin password -S /tmp/mysql_3308.sock
mysql -S /tmp/mysql_3307.sock -p mysql -S /tmp/mysql_3308.sock -p
相关推荐:《mysql教程》
以上就是MySQL如何进行安装部署的详细内容,更多请关注gxlcms其它相关文章!