linux环境搭建mysql5.7总结
以下安装方式,在阿里云与腾讯云服务器上都测试可用。
一、进入到opt目录下,执行:
[root@master opt]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
解压:
[root@master opt]# tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
修改名字:
[root@master opt]# mv mysql-5.7.26-linux-glibc2.12-x86_64/ mysql-5.7.26
移动到/usr/local
[root@master opt]# mv mysql-5.7.26 /usr/local/
创建mysql用户组和用户:
[root@master opt]# groupadd mysql
[root@master opt]# useradd -r -g mysql mysql
进入/usr/local/mysql-5.7.26/目录下,创建一个/data/mysql目录
[root@master opt]# cd /usr/local/mysql-5.7.26/
[root@master opt]# mkdir data
[root@master opt]# cd data/
[root@master opt]# mkdir mysql
对该目录进行授权设置:
[root@master opt]# chown mysql:mysql -R ../data/mysql/
设置vim /etc/my.cnf参数
[mysqld]
bind-address=xxx.xxx.xxx.xxx
port=3306
user=mysql
basedir=/usr/local/mysql-5.7.26
datadir=/usr/local/mysql-5.7.26/data/mysql
socket=/tmp/mysql.sock
log-error=/usr/local/mysql-5.7.26/data/mysql/mysql.err
pid-file=/usr/local/mysql-5.7.26/data/mysql/mysql.pid
#character config
character_set_server=utf8
symbolic-links=0
[client]
socket=/tmp/mysql.sock
初始化mysql:
进入到/usr/local/mysql-5.7.26/bin目录,执行
[root@master opt]# ./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql-5.7.26/ --datadir=/usr/local/mysql-5.7.26/data/mysql/ --user=mysql --initialize
获取初始化生成的密码:zuN4F%E)R!q3
[root@master bin]# cat /usr/local/mysql-5.7.26/data/mysql/mysql.err
2021-10-20T08:09:00.331096Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-10-20T08:09:01.371244Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-10-20T08:09:01.495582Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-10-20T08:09:01.557026Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: fc058b1f-317c-11ec-adb1-00163e061e0a.
2021-10-20T08:09:01.558519Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-10-20T08:09:01.558927Z 1 [Note] A temporary password is generated for root@localhost: zuN4F%E)R!q3
先进入/usr/local/mysql-5.7.26/support-files目录,看到有mysql.server脚本——
[root@master mysql-5.7.26]# pwd
/usr/local/mysql-5.7.26
[root@master mysql-5.7.26]# ll
total 56
drwxr-xr-x 2 root root 4096 Oct 20 15:59 bin
-rw-r--r-- 1 7161 31415 17987 Apr 13 2019 COPYING
drwxr-xr-x 3 root root 4096 Oct 20 15:29 data
drwxr-xr-x 2 root root 4096 Oct 20 15:27 docs
drwxr-xr-x 3 root root 4096 Oct 20 15:27 include
drwxr-xr-x 5 root root 4096 Oct 20 15:27 lib
drwxr-xr-x 4 root root 4096 Oct 20 15:27 man
-rw-r--r-- 1 7161 31415 2478 Apr 13 2019 README
drwxr-xr-x 28 root root 4096 Oct 20 15:27 share
drwxr-xr-x 2 root root 4096 Oct 20 15:27 support-files
[root@master mysql-5.7.26]# cd support-files/
[root@master support-files]# ll
total 24
-rw-r--r-- 1 7161 31415 773 Apr 13 2019 magic
-rwxr-xr-x 1 7161 31415 1061 Apr 13 2019 mysqld_multi.server
-rwxr-xr-x 1 7161 31415 894 Apr 13 2019 mysql-log-rotate
-rwxr-xr-x 1 7161 31415 10576 Apr 13 2019 mysql.server
启动执行:
[root@master support-files]# ./mysql.server start
Starting MySQL. [ OK ]
然后切换到/usr/local/mysql-5.7.26/bin目录,执行进入mysql的指令:
[root@master bin]# ./mysql -u root -p
最后,就是修改密码操作了:
mysql> SET PASSWORD = PASSWORD('xxx');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> ALTER USER 'xxx'@'localhost' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
设置远程访问:
mysql> grant all on *.* to xxx@'%' identified by 'xxx' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
设置开机启动:
先将/usr/local/mysql-5.7.26/support-files/ 文件夹下的mysql.server文件复制到 /etc/rc.d/init.d/ 目录下
[root@master init.d]# cp /usr/local/mysql-5.7.26/support-files/mysql.server /etc/rc.d/init.d/
[root@master init.d]# ll
total 40
-rwxr-xr-x 1 root root 2415 Jun 30 21:19 aegis
-rw-r--r--. 1 root root 18434 Jul 24 2020 functions
lrwxrwxrwx 1 root root 35 Aug 10 11:14 jexec -> /usr/java/latest/.java/init.d/jexec
-rwxr-xr-x 1 root root 10576 Oct 20 16:23 mysql.server
-rw-r--r--. 1 root root 1161 Mar 23 2021 README
将mysql.server修改为mysqld
[root@master init.d]# mv mysql.server mysqld
添加为服务: chkconfig --add mysqld
查看服务列表: chkconfig --list
[root@master init.d]# chkconfig --list
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
aegis 0:off 1:off 2:on 3:on 4:on 5:on 6:off
jexec 0:off 1:on 2:on 3:on 4:on 5:on 6:off
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
3、4、5状态为 on 则表示设置开机启动成功。
linux环境搭建mysql5.7总结的更多相关文章
- Linux环境搭建-在虚拟机中安装Centos7.0
最近在空闲时间学习Linux环境中各种服务的安装与配置,都属于入门级别的,这里把所有的学习过程记录下来,和大家一起分享. 我的电脑系统是win7,所以我需要在win7上安装一个虚拟机-VMware,然 ...
- 【菜鸟学习Linux】-第三章- Linux环境搭建-使用VMware9安装Ubuntu 12.04系统
上一步,我们安装了VMware9虚拟机,现在我们就是用它来安装Ubuntu12.04系统,至于Ubuntu是什么,我就不废话了,大家google一下,比我讲的清楚,好了,开始干活! Ubuntu官网下 ...
- Windows及Linux环境搭建Redis集群
一.Windows环境搭建Redis集群 参考资料:Windows 环境搭建Redis集群 二.Linux环境搭建Redis集群 参考资料:Redis Cluster的搭建与部署,实现redis的分布 ...
- Linux(一)-- Linux环境搭建
Linux环境搭建 一.虚拟机安装 1.下载地址 https://my.vmware.com/web/vmware/info/slug/desktop_end_user_computing/vmwar ...
- Linux(一)—— Linux环境搭建
Linux环境搭建 一.虚拟机安装 1.下载地址 https://my.vmware.com/web/vmware/info/slug/desktop_end_user_computing/vmwar ...
- Linux环境搭建及基础操作
一.Linux环境搭建 1.安装虚拟机软件(VMWare,Parallel) 虚拟机的作用:将本来不是适合当前操作系统的分区虚拟化成适合当前操作系统的分区格式 2.新建虚拟机: 类似买了一台新的电脑, ...
- 【转】Linux环境搭建FTP服务器与Python实现FTP客户端的交互介绍
Linux环境搭建FTP服务器与Python实现FTP客户端的交互介绍 FTP 是File Transfer Protocol(文件传输协议)的英文简称,它基于传输层协议TCP建立,用于Interne ...
- centos 8 集群Linux环境搭建
一.集群Linux环境搭建 1. 注意事项 1.1 windows系统确认所有的关于VmWare的服务都已经启动 打开任务管理器->服务,查看五个VM选项是否打开. 1.2 确认好VmWare生 ...
- Unix/Linux环境C编程入门教程(4) Debian Linux环境搭建
Unix/Linux版本众多,我们推荐Unix/Linux初学者选用几款典型的Unix/Linux操作系统进行学习. 1.广义的Debian是指一个致力于创建自由操作系统的合作组织及其作品,由于Deb ...
- [.Net跨平台]部署DTCMS到Jexus遇到的问题及解决思路---Linux环境搭建
最近朋友托我帮忙研究如何把一个DTCMS部署到Linux下,经过1天的研究,部署基本成功,可能有些细节还未注意到,现在把心得分享一下.过程比预期的要简单 身为.Net程序员,这个问题的第一步可能就是如 ...
随机推荐
- Java 工程文件的 .gitignore
以下是一个排查 Java 工程文件的 .gitignore 文件示例: # Java 编译器生成的文件 *.class # Maven 生成的文件夹 target/ # Eclipse 生成的文件夹 ...
- 2020年9月至10月 Splashtop 新功能
Splashtop 已为 Splashtop Business Access.Splashtop Remote Support.Splashtop SOS 和 Splashtop On-Prem ...
- C语言:判断是否为素数,并且打印素数表
/* 构造素数表, 只需要用数字除以已经判断出来的数是否能整除就行, 不需要除以这个数之前所有的数字, 前提是这个数除以的素数是要比他自己小的 */ 注意一点:int ...
- C 语言编程 — 数据类型的别名
目录 文章目录 目录 前文列表 typedef 关键字 typedef 和预处理器指令 #define 的区别 前文列表 <程序编译流程与 GCC 编译器> <C 语言编程 - 基本 ...
- PageOffice既保存Word文件中指定区域的数据又保存整篇文件
一.首先在word文件中给需要在后台获取数据的区域设置以PO_开头的书签. 二.通过pageoffice在线打开文件并编辑保存.有两种打开文件的模式 1.普通编辑模式(docNormalEdit) 普 ...
- WPF自定义控件,如何使得xaml涉及器中的修改能立即反应到预览
这是我无意中发现的,xaml中设置的是依赖属性而不是包装器,所以我们可以直接在注册依赖属性那里设置回调,触发某个控件重绘,比如本身或父控件重绘. xaml设计器就会实时更新 1 // !!!由于xam ...
- 2024-05-22:用go语言,你有一个包含 n 个整数的数组 nums。 每个数组的代价是指该数组中的第一个元素的值。 你的目标是将这个数组划分为三个连续且互不重叠的子数组。 然后,计算这三个子数
2024-05-22:用go语言,你有一个包含 n 个整数的数组 nums. 每个数组的代价是指该数组中的第一个元素的值. 你的目标是将这个数组划分为三个连续且互不重叠的子数组. 然后,计算这三个子数 ...
- Ubuntu20.04安装MySQL5.7
ubuntu 20.04系统自带源直接安装的是MySQL 8.0,要安装MySQL 5.7的话,需要先换源. 1.换源 sudo cp /etc/apt/sources.list /etc/apt/s ...
- Android 13 - Media框架(33)- ACodec(九)
关注公众号免费阅读全文,进入音视频开发技术分享群! 前一节我们学习了Output Format Changed事件是如何上抛并且被处理的,这一节我们紧接着来学习OutputBuffer是如何上抛并且被 ...
- Redis 常用的数据结构简介与实例测试【Redis 系列二】
〇.都有哪些数据结构? Redis 提供了较为丰富的数据类型,常见的有五种:String(字符串),Hash(哈希),List(列表),Set(集合).Zset(有序集合). 随着 Redis 版本的 ...