linux mysql-5.7.9免编译版安装

时间:2022-05-26 10:02:36
好像mysql5.7之后的tag包,不用编译了,可以直接安装.解压MySQL-5.7.9的安装包后,打开INSTALL-BINARY,里面有详细的安装命令,这里稍加修改即可正确安装

shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /data
shell> tar zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
shell> mv mysql-5.7.9-linux-glibc2.5-x86_64 mysql-5.7.9
shell> cd mysql-5.7.9
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> su mysql
shell> bin/mysqld --initialize --user=mysql --basedir=/data/mysql-5.7.9 --datadir=/data/mysql-5.7.9/data # MySQL 5.7.6 and up,记录生成的随机密码
shell> bin/mysql_ssl_rsa_setup --datadir=/data/mysql-5.7.9/data             # MySQL 5.7.6 and up
shell> exit
shell> chown -R root .
shell> chown -R mysql data
shell> cp support-files/mysql.server /etc/init.d/mysql
shell> cp support-files/my-default.cnf /etc/my.cnf
shell> vim /etc/my.cnf #修改为以下配置
basedir = /data/mysql-5.7.9
datadir = /data/mysql-5.7.9/data
shell> service mysql start
shell> service mysql status
shell> chkconfig --add mysql
shell> chkconfig mysql on


shell> bin/mysql -u root -p #连接数据库
mysql> set password=password('123456');  #修改root密码
mysql> exit
shell> vim /etc/profile
export MYSQL_HOME=/data/mysql-5.7.9
export PATH=$PATH:$MYSQL_HOME/bin