mysql 5.7.24 二进制安装

下载地址 https://downloads.mysql.com/archives/community/
在这里插入图片描述

#1 下载解压移动
wegt https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
tar xf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql{-5.7.24-linux-glibc2.12-x86_64/,}
cd /usr/local/mysql

#2 创建 用户 用户组 授权
groupadd mysql
useradd  -r -g mysql mysql
chown -R mysql:mysql  /usr/local/mysql

#3 初始化
./bin/mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

初始化过程中 报错 1 缺少依赖库

error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

解决 报错 1 安装依赖库

yum -y install libaio* numactl

初始化成功提示
注意:mysql5.7版本之上会初始化话一个密码,在这里要记住这个初始化密码在最后一行,在下面初次登录会用上。

[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
[Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
[Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
[Warning] Using pre 5.5 semantics to load error messages from /usr/local/mysql/share/.
[Warning] If this is not intended, refer to the documentation for valid usage of --lc-messages-dir and --language parameters.
[Warning] InnoDB: New log files created, LSN=45790
[Warning] InnoDB: Creating foreign key constraint system tables.
[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: caecfde9-7f3e-11ec-bd93-000c29f7621c.
[Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
[Note] A temporary password is generated for root@localhost: =5JWeZdsg#2l

#4 创建配置文件
vi /etc/my.cnf

[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
socket = /usr/local/mysql/tmp/mysql.sock
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

[client]
port=3306
socket = /usr/local/mysql/tmp/mysql.sock

#5 启动
/usr/local/mysql/support-files/mysql.server start

启动报错

Starting MySQL.2022-01-27T07:34:37.293092Z mysqld_safe Directory '/usr/local/mysql/tmp' for UNIX socket file don't exists.
 ERROR! The server quit without updating PID file (/usr/local/mysql/data/bx.pid).

查看 data/*err 日志

cat data/bx.err
mysqld_safe Logging to '/usr/local/mysql/data/bx.err'.
mysqld_safe Directory '/usr/local/mysql/tmp' for UNIX socket file don't exists.

解决 启动报错

mkdir /usr/local/mysql/tmp
chown -R mysql:mysql  /usr/local/mysql

重新启动
/usr/local/mysql/support-files/mysql.server start
提示如下 则表示启动成功
Starting MySQL.. SUCCESS!

# 查看进程
ps aux | grep mysql

修改密码

#连接 mysql 
/usr/local/mysql/bin/mysql -uroot -p=5JWeZdsg#2l 
alter user 'root'@'localhost' identified by 'root';

加入system 管理

vim /usr/lib/systemd/system/mysqld.service


[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=mysql
Group=mysql

ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 10000


chmod 644 /usr/lib/systemd/system/mysqld.service


# 添加环境变量与开机自启
echo 'PATH="$PATH:/usr/local/mysql/bin/"' >> /etc/profile && source /etc/profile
systemctl enable mysqld
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要进行MySQL 5.7二进制安装,可以按照以下步骤进行操作: 1. 首先,将MySQL二进制包解压到/usr/local目录下。你可以使用以下命令: ``` tar xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ ``` 2. 接下来,配置启动文件并启动MySQL。你可以使用以下命令: ``` cp support-files/mysql.server /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on service mysqld start ``` 3. 然后,需要初始化MySQL。根据你的操作系统不同,可以使用不同的命令进行安装。如果是CentOS系统,使用以下命令: ``` cd /usr/local/mysql yum -y install libaio* ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/mydata/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp ``` 如果是Ubuntu系统,使用以下命令: ``` cd /usr/local/mysql apt-get -y install libaio-dev ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/mydata/data --innodb_undo_tablespaces=3 --explicit_defaults_for_timestamp ``` 这些步骤将会安装并初始化MySQL 5.7二进制版本。请确保按照指定的路径和命令进行操作,以确保安装过程顺利完成。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [MySQL5.7 二进制安装](https://blog.csdn.net/weixin_68330286/article/details/124588446)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值