Maison >base de données >tutoriel mysql >Comment installer et déployer MySQL
Cet article vous présentera comment installer et déployer MySQL. Il a une certaine valeur de référence. Les amis dans le besoin peuvent s'y référer. J'espère qu'il sera utile à tout le monde.
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 EOF4. Configurez le fichier de démarrage
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
tutoriel mysql"
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!