MySQL二进制安装

  • Post author:
  • Post category:MySQL
  • Page Views 903 阅读

1.下载并解压安装包

cd /usr/local/src
tar xf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz

2.下载依赖包

yum install libaio libaio-devel -y

3.创建MySQL目录

mv /etc/my.cnf /etc/my.cnf.`date +%Y%m%d%H%M%S`.bak
mkdir -p /study/usr/local/mysql5718
mkdir -p /study/data/mysql mkdir -p /study/data/slowlog mv mysql-5.7.18-linux-glibc2.5-x86_64 /study/usr/local/mysql5718 ln -s /study/usr/local/mysql5718 /study/usr/local/mysql

4.创建用户

useradd -s /sbin/nologin -M mysql

5.授权MySQL数据目录

chown -R mysql.mysql /study/data/mysql 
chown -R mysql.mysql /study/usr/local/mysql 
chown -R mysql.mysql /study/usr/local/mysql5718 
chown -R mysql.mysql /study/data/slowlog

6.配置my.conf

my.conf配置文件

7.初始化MySQL

/study/usr/local/mysql/bin/mysqld --initialize-insecure --defaults-file=/etc/my.cnf --user=mysql --datadir=/study/data/mysql --basedir=/study/usr/local/mysql 

8.配置启动脚本并添加开机启动

cp /study/usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on

9.配置动态链接库目录

cat > /etc/ld.so.conf.d/mysql-x86_64.conf<<'EOF'
/study/usr/local/mysql/lib 
EOF

ldconfig

10.设置环境变量

vim /etc/profile

export PATH=$PATH:/study/usr/local/mysql/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/study/usr/local/mysql/lib

source /etc/profile

11.启动MySQL

service mysqld start
或者
/etc/init.d/mysqld start

12.设置root密码

mysql -uroot
SET PASSWORD = PASSWORD('密码'); 
flush privileges;


「 文章如果对你有帮助,请点个赞哦^^ 」 

0

这篇文章有一条评论

评论关闭。