我是靠谱客的博主 饱满发卡,最近开发中收集的这篇文章主要介绍二进制格式mysql安装,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

二进制格式mysql安装

下载下来后,用xftp传到虚拟机

先配好yum源,然后进行二进制格式mysql安装:
[root@localhost ~]# cd /usr/src/
[root@localhost src]# ls
debug
kernels
mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
//创建用户和组
[root@localhost src]# useradd -r -M -s /sbin/nologin mysql
[root@localhost src]# id mysql
uid=995(mysql) gid=992(mysql) groups=992(mysql)
//解压软件至/usr/local/
[root@localhost src]# ls
debug
kernels
mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# tar xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# ls /usr/local/
bin
include
libexec
share
etc
lib
mysql-5.7.37-linux-glibc2.12-x86_64
src
games
lib64
sbin
[root@localhost src]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.37-linux-glibc2.12-x86_64 mysql
[root@localhost local]# ls
bin
games
lib
libexec
sbin
src
etc
include
lib64
mysql
share
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root
6 Jun 21
2021 bin
drwxr-xr-x. 2 root root
6 Jun 21
2021 etc
drwxr-xr-x. 2 root root
6 Jun 21
2021 games
drwxr-xr-x. 2 root root
6 Jun 21
2021 include
drwxr-xr-x. 2 root root
6 Jun 21
2021 lib
drwxr-xr-x. 3 root root
17 Jun 30 10:06 lib64
drwxr-xr-x. 2 root root
6 Jun 21
2021 libexec
drwxr-xr-x. 9 root root 129 Jul
1 01:59 mysql
drwxr-xr-x. 2 root root
6 Jun 21
2021 sbin
drwxr-xr-x. 5 root root
49 Jun 30 10:06 share
drwxr-xr-x. 2 root root
6 Jun 21
2021 src
//修改目录/usr/local/mysql的属主属组
[root@localhost local]# chown -R mysql.mysql mysql
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root
root
6 Jun 21
2021 bin
drwxr-xr-x. 2 root
root
6 Jun 21
2021 etc
drwxr-xr-x. 2 root
root
6 Jun 21
2021 games
drwxr-xr-x. 2 root
root
6 Jun 21
2021 include
drwxr-xr-x. 2 root
root
6 Jun 21
2021 lib
drwxr-xr-x. 3 root
root
17 Jun 30 10:06 lib64
drwxr-xr-x. 2 root
root
6 Jun 21
2021 libexec
drwxr-xr-x. 9 mysql mysql 129 Jul
1 01:59 mysql
drwxr-xr-x. 2 root
root
6 Jun 21
2021 sbin
drwxr-xr-x. 5 root
root
49 Jun 30 10:06 share
drwxr-xr-x. 2 root
root
6 Jun 21
2021 src
//添加环境变量
[root@localhost local]# ls mysql/
bin
include
LICENSE
README
support-files
docs
lib
man
share
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# source /etc/profile.d/mysql.sh
//读一下让它生效
[root@localhost local]# which mysql
/usr/local/mysql/bin/mysql
//include,lib,man文档的操作
[root@localhost local]# ls
bin
games
lib
libexec
sbin
src
etc
include
lib64
mysql
share
[root@localhost local]# cd mysql/
[root@localhost mysql]# ls
bin
include
LICENSE
README
support-files
docs
lib
man
share
[root@localhost mysql]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@localhost mysql]# vi /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
~
[root@localhost mysql]# ldconfig
[root@localhost mysql]# vi /etc/man_db.conf
#
......
MANDATORY_MANPATH
/usr/man
MANDATORY_MANPATH
/usr/share/man
MANDATORY_MANPATH
/usr/local/share/man
MANDATORY_MANPATH
/usr/local/mysql/man
......
//建立数据存放目录
[root@localhost ~]# mkdir -p /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data
[root@localhost ~]# ll /opt/
total 0
drwxr-xr-x. 2 mysql mysql 6 Jul
1 09:26 data
//初始化数据库
[root@localhost ~]# which mysqld
/usr/local/mysql/bin/mysqld
[root@localhost ~]# mysqld --initialize --user=mysql --datadir=/opt/data
......
2022-07-01T01:49:21.922328Z 1 [Note] A temporary password is generated for root@localhost: gL1Cw;oZnjih
//请注意,这个命令的最后会生成一个临时密码,此处密码是gL1Cw;oZnjih
//再次注意,这个密码是随机的,你的不会跟我一样,一定要记住这个密码,因为一会登录时会用到
[root@localhost ~]# echo 'gL1Cw;oZnjih' > pass
//把密码暂时记在一个文件里
//生成配置文件
[root@localhost ~]# cat /etc/my.cnf
cat: /etc/my.cnf: No such file or directory
[root@localhost ~]# vi /etc/my.cnf
[mysqld]
//固定写法,表示MySQL主程序
basedir = /usr/local/mysql	//安装位置
datadir = /opt/data
//数据存放位置
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid	//进程id号存放位置
user = mysql
skip-name-resolve	//跳过名称解析,意思是数据库不会用域名来访问
#sql-mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
~
//配置服务启动脚本
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# ls
bin
include
LICENSE
README
support-files
docs
lib
man
share
[root@localhost mysql]# cd support-files
[root@localhost support-files]# ls
magic
mysqld_multi.server
mysql-log-rotate
mysql.server
[root@localhost support-files]# file mysql.server
mysql.server: POSIX shell script, ASCII text executable
[root@localhost support-files]# ll
total 24
-rw-r--r--. 1 mysql mysql
773 Nov 30
2021 magic
-rwxr-xr-x. 1 mysql mysql
1061 Nov 30
2021 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql
894 Nov 30
2021 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Nov 30
2021 mysql.server
[root@localhost support-files]# cp mysql.server mysqld
[root@localhost support-files]# ll
total 36
-rw-r--r--. 1 mysql mysql
773 Nov 30
2021 magic
-rwxr-xr-x. 1 root
root
10576 Jul
2 19:36 mysqld
-rwxr-xr-x. 1 mysql mysql
1061 Nov 30
2021 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql
894 Nov 30
2021 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Nov 30
2021 mysql.server
[root@localhost support-files]# chown -R mysql.mysql mysqld
[root@localhost support-files]# ll
total 36
-rw-r--r--. 1 mysql mysql
773 Nov 30
2021 magic
-rwxr-xr-x. 1 mysql mysql 10576 Jul
2 19:36 mysqld
-rwxr-xr-x. 1 mysql mysql
1061 Nov 30
2021 mysqld_multi.server
-rwxr-xr-x. 1 mysql mysql
894 Nov 30
2021 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Nov 30
2021 mysql.server
[root@localhost support-files]# vi mysqld
......
basedir=/usr/local/mysql
datadir=/opt/data
......
//启动mysql
[root@localhost ~]# /usr/local/mysql/support-files/mysqld start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
SUCCESS!
[root@localhost ~]# ss -antl
State
Recv-Q Send-Q
Local Address:Port
Peer Address:Port Process
LISTEN 0
128
0.0.0.0:22
0.0.0.0:*
LISTEN 0
80
*:3306
*:*
LISTEN 0
128
[::]:22
[::]:*
[root@localhost ~]# ps -ef|grep mysqld
root
3100
1
0 19:43 pts/1
00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data --pid-file=/opt/data/mysql.pid
mysql
3288
3100
0 19:43 pts/1
00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --pid-file=/opt/data/mysql.pid --socket=/tmp/mysql.sock --port=3306
root
3324
2941
0 19:44 pts/1
00:00:00 grep --color=auto mysqld
//修改密码
//使用临时密码登录
[root@localhost ~]# ls
anaconda-ks.cfg
pass
[root@localhost ~]# cat pass
zqeb7ke/7jpI
[root@localhost ~]# mysql -uroot -p'zqeb7ke/7jpI'
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
[root@localhost ~]# dnf provides libncurses.so.5
......
[root@localhost ~]# dnf -y install ncurses-compat-libs
......
[root@localhost ~]# ls
anaconda-ks.cfg
pass
[root@localhost ~]# cat pass 
zqeb7ke/7jpI
[root@localhost ~]# mysql -uroot -p'zqeb7ke/7jpI'
......
mysql> set password=password('12345');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit
Bye
[root@localhost ~]# mysql -uroot -p'12345'
......
//设置开机自启
[root@localhost ~]# cp /usr/lib/systemd/system/sshd.service mysqld.service
[root@localhost ~]# ls
anaconda-ks.cfg
mysqld.service
pass
[root@localhost ~]# vim mysqld.service
[Unit]
Description=mysql server daemon
After=network.target sshd-keygen.target
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysqld start
ExecStop=/usr/local/mysql/support-files/mysqld stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
~
[root@localhost ~]# mv mysqld.service /usr/lib/systemd/system/
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/selinux/config
[root@localhost ~]# systemctl start mysqld
[root@localhost ~]# systemctl enable mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@localhost ~]# systemctl status mysqld
● mysqld.service - mysql server daemon
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; e>
Active: active (running) since Mon 2022-07-04 01:29:08 CS>
......

最后

以上就是饱满发卡为你收集整理的二进制格式mysql安装的全部内容,希望文章能够帮你解决二进制格式mysql安装所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部