centos7 安装 mysql5.7 (复制粘贴系列)
- mysql 下载链接:
- centos7 镜像下载链接:
- 也可以在服务器上面: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;
【centos7 安装 mysql5.7 (复制粘贴系列)】set password for root@localhost = password('123123');flush privileges;
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 短短几个月,安装包从200M涨到354M,微信越来越臃肿了?
- 便捷安装、功能强大的手机稳定器 大疆OM 4
- 老旧台式机也可升级WiFi6和蓝牙5.1,仅安装百元网卡即可
- 创新|凯芙隆|乐帕免安装反渗透净水机,让每一滴水都喝的安心
- 在Linux系统中安装深度学习框架Pytorch
- OpenCart安装和设置亚马逊支付和登录AmazonPay
- 行业专家建议:中国销售的智能手机,必须强制安装华为鸿蒙系统?
- centos7 安装 MongoDB (复制粘贴系列)
- 电脑内存小,想安装的软件安装不了,这个软件抵一百个软件
- 外媒:Win10或在明年支持安装和运行Android应用