本文主要是介绍Centos系统二进制安装mysql5.7.44、添加环境变量、复制启动脚本、初始化数据库、设置用户密码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
MySQL :: Download MySQL Community Server (Archived Versions)
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
删除默认存在的mariadb-libs
rpm -e mariadb-libs --nodeps
安装mysql
cd /usr/local/src/ && mkdir mysql && cd mysql
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
tar xf mysql-5.7.44-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.44-linux-glibc2.12-x86_64 /usr/local/mysql/
添加永久环境变量
sed -i '$aexport PATH=$PATH:/usr/local/mysql/bin' /etc/profile
source /etc/profile
创建mysql用户
useradd mysql -l
准备mysql数据库目录
mkdir -p /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql
准备mysql配置文件
cat <<jingyu >> /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
pid-file=/usr/local/mysql/data/mysqld.pid
log-error=/usr/local/mysql/data/mysql.err
socket=/tmp/mysql.sock
jingyu
初始化mysql数据库
mysqld --defaults-file=/etc/my.cnf --initialize --user=mysql
之后会在data目录下生成这些文件
复制启动脚本
由于之前做了环境变量可直接复制到/usr/local/mysql/bin下
ln -s /usr/local/mysql/support-files/mysql.server /usr/local/mysql/bin/
启动mysql
mysql.server start
过滤临时密码
临时密码需要启动mysql在后才会有。
grep password /usr/local/mysql/data/mysql.err
mysql -uroot -p
设置用户密码
alter user root@localhost identified by 'CSDN-jingyu1610';
这篇关于Centos系统二进制安装mysql5.7.44、添加环境变量、复制启动脚本、初始化数据库、设置用户密码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!