MySQL 5.7原生通用二进制格式安装包安装过程

官方文档

文件说明

Directory Contents of Directory
bin mysqld server, client and utility programs
docs MySQL manual in Info format
man Unix manual pages
include Include (header) files
lib Libraries
share Error messages, dictionary, and SQL for database installation
support-files Miscellaneous support files
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql 
shell> bin/mysql_ssl_rsa_setup              
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

为了方便,建立了以下一系列shell命令(不敢妄称脚本),当然,也就固化了安装目录为/usr/local/mysql/,数据文件位置/data。请根据需要修改或是直接拍命令。

[root@CentOS712 ~]# vim MySQL_install.sh 

  3 # Date:     07-05-2019
  4 # Comment:  install mysql 5.7.26 on el7
  5 #********************
  6 
  7 function precheck(){
  8     if [ `cat /etc/system-release | awk -F'.' '{print $1}' | cut -d ' ' -f4` -eq 7 ];then
  9         echo -e "Your system os is version 7......Succeed!\n"
 10     else if [ `cat /etc/system-release | awk -F'.' '{print $1}' | cut -d ' ' -f4` -eq 6 ];then
 11         echo -e "Your system os is version 6......Failed!\nThis check is vital, quit forcely!\n"
 12         exit 1
 13         fi
 14     fi
 15 }
 16 
 17 function process(){
 18     echo -e "\n Processing......\n"
 19     useradd -r -u 600 mysql
 20     mkdir /data
 21     chown -R mysql. /data
 22     tar -zxvf $1 -C /usr/local/
 23     local var_one=`ls /usr/local/ | grep mysql`
 24     ln -s /usr/local/${var_one} /usr/local/mysql
 25     chown -R mysql. /usr/local/mysql
 26     chown -R mysql. /usr/local/${var_one}
 27     /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data
 28     cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
 29     sed -i '45,48s/basedir=/&\/usr\/local\/mysql/' /etc/init.d/mysqld
 30     sed -i '45,48s/datadir=/&\/data/' /etc/init.d/mysqld
 31     echo "export PATH=\$PATH:/usr/local/mysql/bin" >> /etc/profile.d/mysql_env.sh
 32     . /etc/profile.d/mysql_env.sh
 33     echo -e "\n Processing Down"
 34 }
 35 
 36 
 37 precheck
 38 process $1
"MySQL_install.sh" 38L, 1272C  

用法: ./MySQL_install.sh mysql-5.7.26-el7-x86_64.tar.gz

终端会显示临时密码

然后

[root@rhel] service mysqld start
[root@CentOS712 ~]# mysql -uroot -p
Enter password: 键入临时密码
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> \q
Bye
posted @ 2019-05-07 20:32  素丶素  阅读(300)  评论(0编辑  收藏  举报