时间:2021-07-01 10:21:17 帮助过:1人阅读
可以直接去官方下载二进制包
需要先卸载mariadb
rpm -e mariadb-libs --nodeps
直接进行解压,移动
tar zxf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.20-linux-glibc2.12-x86_64 /usr/local/mysql
创建用户和组
groupadd mysql useradd -r -g mysql -s /bin/false mysql
编辑主配置文件(仅满足启动,其他配置可自行加入)
echo [mysqld] > /etc/my.cnf echo socket=/tmp/mysql.sock >>/etc/my.cnf echo basedir=/usr/local/mysql >> /etc/my.cnf echo datadir=/usr/local/mysql/data >> /etc/my.cnf
创建数据目录并授予权限
mkdir /usr/local/mysql/data cd /usr/local/mysql/ chmod 750 data chown -R mysql . chgrp -R mysql .
添加环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile source /etc/profile
初始化
bin/mysqld --initialize --user=mysql
开机自启,并启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld systemctl daemon-reload systemctl enabled mysql systemctl start mysql
设置MYSQL密码
cd /usr/local/mysql/ bin/mysqladmin -u root -password 123456
设置密码后即可正常登陆,推荐使用此方法
MYSQL安装之二进制
标签:mysql安装二进制