mysql在linux情况下安装(.tar.gz包)安装图文教程
目录1、去官网下载mysql安装包(下面是下载链接,可自行下载)
2、通过xftp将tar包上传到Linux情况下
3、解压安装包,将安装包放到指定目录(这里放到opt下)
4、安装
4、制作MySQL启动文件
5、修改启动脚本
6、设置情况变量
7、启动MySQL服务
8、登录mysql举行设置
9、在防火墙上给mysql开3306端口,供用户访问
10、关闭MySQL服务
1、去官网下载mysql安装包(下面是下载链接,可自行下载)
https://www.mysql.com/downloads/ https://downloads.mysql.com/archives/community/ https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz 2、通过xftp将tar包上传到Linux情况下
https://img-blog.csdnimg.cn/direct/4cc0ff9025504e638833c38f5f182dbb.png
3、解压安装包,将安装包放到指定目录(这里放到opt下)
tar -zxvf /opt/mysql-5.7.43-el7-x86_64.tar.gz -C /opt
目录更换为本身的目录
https://img-blog.csdnimg.cn/direct/0da81f6a276a4d8e94d170bfaec0a02d.png
4、安装
# 添加mysql组 groupadd mysql # 创建用户mysql并将友爱加到组mysql useradd -g mysql mysql # 进入mysql目录下、创建data文件夹
cd /opt/mysql-5.7.43-el7-x86_64/
mkdir data
# 初始化数据库:指定用户、指定安装目录、指定数据目录
./bin/mysqld --initialize --user=mysql --basedir=/opt/mysql-5.7.43-el7-x86_64 --datadir=/opt/mysql-5.7.43-el7-x86_64/data
https://img-blog.csdnimg.cn/direct/63dd3dedebaf4a4dbdc772cf25b58661.png
注:实行尾部 “0i8!JKQg2Tne”是初始化暗码,暗码是随机产生的,每次都不一样。
# 给MySQL文件目录授权 -R是渗出授权
chmod -R 777 /opt/mysql-5.7.43-el7-x86_64
https://img-blog.csdnimg.cn/direct/76ed91967a6947c78d8166364fb2cbff.png
4、制作MySQL启动文件
# 拷贝启动文件,并改名为mysqld cp support-files/mysql.server /etc/init.d/mysqld # 设置启动文件的权限 chmod 777 /etc/init.d/mysqld # 拷贝文件 cp bin/my_print_defaults /usr/bin/ https://img-blog.csdnimg.cn/direct/a47b31176b594d6f9902a736246ea44e.png 5、修改启动脚本
先修改”/etc/init.d/mysqld“
vim /etc/init.d/mysqld
# vi /etc/init.d/mysqld # 设置MySQL的主目录 basedir=/opt/mysql-5.7.43-el7-x86_64 # 设置MySQL的数据目录 datadir=/opt/mysql-5.7.43-el7-x86_64/data # 设置MySQL的端口 port=3306 https://img-blog.csdnimg.cn/direct/782d62298d464e1a95a7cef59c009f27.png 然后设置 ” /etc/my.cnf “ vim /etc/my.cnf
datadir=/opt/mysql-5.7.43-el7-x86_64/data
basedir=/opt/mysql-5.7.43-el7-x86_64
socket=/opt/mysql-5.7.43-el7-x86_64/mysql.sock
user=mysql
tmpdir=/tmp
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
log-error=/opt/mysql-5.7.43-el7-x86_64/data/error.log
pid-file=/opt/mysql-5.7.43-el7-x86_64/mysql.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
https://img-blog.csdnimg.cn/direct/e9a988c15e5649638d42127f672c9a17.png
6、设置情况变量
设置情况变量文件 “/etc/profile”
export MYSQL_HOME=/opt/mysql-5.7.43-el7-x86_64
export PATH=$PATH:$MYSQL_HOME/bin
https://img-blog.csdnimg.cn/direct/dccb1dafbd0e40f497f0fcbc9f8dbcd8.png
收效情况变量
source /etc/profile
7、启动MySQL服务
service mysqld start
https://img-blog.csdnimg.cn/direct/17ca3ca98c6a4d1ea1a56e990f600646.png
8、登录mysql举行设置
暗码输入上面初始化天生的初始化暗码:“0i8!JKQg2Tne”
https://img-blog.csdnimg.cn/direct/9b254a6817044408a714cc097fe81821.png
# 修改暗码:注意暗码不能太容易。 set password for root @localhost = password( '123456' ); # 设置 MySQL 远程可以登录。 use mysql; update user set host = '%' where user = 'root' ; flush privileges; https://img-blog.csdnimg.cn/direct/2aff1a97ed054df0b925833542c93aa3.png 9、在防火墙上给mysql开3306端口,供用户访问
firewall-cmd --zone = public --add-port = 3306 /tcp --permanent 10、关闭MySQL服务
service mysqld stop https://img-blog.csdnimg.cn/direct/8f9af2ecff5f4c469470d52266e80d91.png
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]