• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

MySQL Community Server 5.7 安装指定数据目录过程小记

开发技术 开发技术 5小时前 2次浏览

操作系统:CentOS 7/8
MySQL版本:MySQL Community Server 5.7.34

过程:
wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar

yum install libaio #CentOS 8 用dnf,CentOS 7用yum
yum install libncurses* #CentOS 8需要
yum install net-tools #CentOS 7需要

rpm -ivh mysql-community-common-5.7.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.34-1.el7.x86_64.rpm

mkdir /data/mysql/
chown mysql:mysql /data/mysql/
chmod 750 /data/mysql/
/usr/sbin/mysqld –initialize –user=mysql –datadir=/data/mysql/

cd /etc/
cp my.cnf my.cnf.bak
vi my.cnf

semanage fcontext -a -t mysqld_db_t “/data/mysql(/.*)?” #启用了SELinux的必须
restorecon -Rv /data/mysql #启用了SELinux的必须

service mysqld restart
—————————-#至此安装完成,以后是初始化配置

grep ‘temporary password’ /var/log/mysqld.log #获取临时密码
mysql -u root -p
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘password’;
mysql> GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> CREATE USER ‘username’@’host’ IDENTIFIED BY ‘password’;
mysql> GRANT ALL ON . TO ‘username’@’%’;
mysql> exit

———————————-#开启防火墙例外
firewall-cmd –zone=public –add-port=3306/tcp –permanent
firewall-cmd –reload


程序员灯塔
转载请注明原文链接:MySQL Community Server 5.7 安装指定数据目录过程小记
喜欢 (0)