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

官方文档

文件说明

DirectoryContents of Directory
binmysqld server, client and utility programs
docsMySQL manual in Info format
manUnix manual pages
includeInclude (header) files
libLibraries
shareError messages, dictionary, and SQL for database installation
support-filesMiscellaneous 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

转载于:https://www.cnblogs.com/MimiSnowing/p/10827875.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值