龙空技术网

centos7 安装 mysql5.7 (复制粘贴系列)

97牛肉面 437

前言:

今天大家对“centos7镜像下载”大概比较关注,看官们都想要分析一些“centos7镜像下载”的相关知识。那么小编在网络上汇集了一些有关“centos7镜像下载””的相关资讯,希望各位老铁们能喜欢,你们快快来了解一下吧!

mysql 下载链接: 镜像下载链接:也可以在服务器上面:wget

1.创建基础目录(已经有的话,请跳过)

# 用来存储我们下载好的一些文件或者软件mkdir -p /home/service# 用来存储配置文件mkdir -p /home/config# 用来存储日志mkdir -p /home/logs# sh脚本mkdir -p /home/sh
安装wget:yum install wget2. 下载或者上传mysql5.7的文件
cd /home/service# 如果没有安装wget, yum install wgetwget 
3. 创建mysql配置文件(复制全部,粘贴运行就好了)
mkdir -p /home/config/mysqlmkdir -p /home/logs/mysql# 创建mysql配置文件cat <<'EOF'> /home/config/mysql/my.cnf[mysqld]character_set_server=utf8mb4basedir=/home/service/mysqldatadir=/home/service/mysql/dataport = 3306log-error=/home/logs/mysql/mysqld.log#不开启sql严格模式sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"slow_query_log=ONslow_query_log_file=/home/logs/mysql/slowquery.loglong_query_time=3log-queries-not-using-indexes=ONlower_case_table_names=1EOF
4.创建安装脚本(复制全部,粘贴运行就好了)
# 创建mysql安装脚本cat <<'EOF'> /home/sh/mysql_install.shcd /home/servicetar -zxvf /home/service/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gzmv /home/service/mysql-5.7.30-linux-glibc2.12-x86_64 /home/service/mysqlgroupadd mysqluseradd -r -g mysql mysqlchown -R mysql:mysql /home/service/mysqlchown -R mysql:mysql /home/logs/mysqlcp -rf /home/config/mysql/my.cnf /etc/my.cnf/home/service/mysql/bin/mysqld --initialize --user=mysql --datadir=/home/service/mysql/data --basedir=/home/service/mysqlcp /home/service/mysql/support-files/mysql.server /etc/init.d/mysqlsed -i "s/^basedir=$/basedir=\/home\/service\/mysql/g" /etc/init.d/mysqlsed -i "s/^datadir=$/datadir=\/home\/service\/mysql\/data/g" /etc/init.d/mysqlchkconfig --add mysqlchkconfig mysql onchkconfig --level 345 mysql onservice mysql startEOF
5.执行脚本(复制全部,粘贴运行就好了)
sh /home/sh/mysql_install.sh
6. 添加到系统环境(复制全部,粘贴运行就好了)
cat <<'EOF'>> /etc/profileexport MYSQL_HOME=/home/service/mysqlexport PATH=$PATH:$MYSQL_HOME/binEOF
7. 重新加载环境(复制全部,粘贴运行就好了)
source /etc/profile# 检测是否安装完成mysql -V
8.查看初始密码(复制全部,粘贴运行就好了)
grep 'password' /home/logs/mysql/mysqld.log#2020-08-31T04:56:25.142596Z 1 [Note] A temporary password is generated for root@localhost: u6whd?esl0dI
安装完成啦,如果能帮到您,多多关注哦,谢谢,点个赞呗题外话:mysql 停止,启动,重启
service stop mysqlservice start mysqlservice restart mysql
题外话:mysql 登录
mysql -u root -p# 或者/home/service/mysql/bin/mysql -u root -p
题外话:修改mysql 初始密码

SET PASSWORD = PASSWORD('123123');ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;flush privileges;
set password for root@localhost = password('123123');flush privileges;

标签: #centos7镜像下载