全部
常见问题
产品动态
精选推荐

小内存服务器装不了MySQL 8?试试这个CentOS编译安装大法!

管理 管理 编辑 删除

上期我们分享了CRMEB多商户系统(Java)升级MySQL 8的完整攻略,其中提到一个常见问题——如果你的服务器内存只有4G,或安装了宝塔这类面板,可能直接安装MySQL 8会失败。

当时我们建议:可以通过命令行手动编译安装,再外链到面板进行管理。

是不是听起来有点麻烦?别急,今天就是来助攻的!

这篇文章手把手带你在CentOS服务器上编译安装MySQL 8,专治各种环境不符、内存不足、安装失败。如果你也卡在这个环节,赶紧往下看吧!

7e212202510141747184646.png


1、下载MySQL 8安装包

官方地址https://dev.mysql.com/downloads/mysql/

e5985202510141748208060.png


2、上传、解压MySQL

将下载好的MySQL包上传到/usr/local/目录下,根据包的后缀选择解压语句。

tar -zxvf mysql-8.0.43-linux-glibc2.28-x86\_64.tar.gz

或者

tar -xvf mysql-8.0.43-linux-glibc2.28-x86\_64.tar.xz


目录改名:

mv  mysql-8.0.43-linux-glibc2.28-x86\_64 mysql-8.0.43
#创建data文件夹 存储文件

cd mysql-8.0.34
mkdir data

3、创建用户组以及密码

groupadd mysql

useradd -g mysql mysql

#授权用户

chown -R mysql.mysql /usr/local/mysql-8.0.34

4、切换到bin目录下,安装MySQL

cd bin

./mysqld --user=mysql --lower\_case\_table\_names=1 --basedir=/usr/local/mysql-8.0.34 --datadir=/usr/local/mysql-8.0.34/data/ --initialize

34f73202510141748389340.png

Tips:☝️得到临时密码,这里的密码记得保存‼️


5、编辑my.cnf文件

vi /etc/my.cnf

添加以下内容:

[mysqld]

basedir=/usr/local/mysql-8.0/

datadir=/usr/local/mysql-8.0/data/

socket=/tmp/mysql.sock

character-set-server=UTF8MB4

symbolic-links=0

lower\_case\_table\_names=1

6、添加mysqld服务到系统

cd /usr/local/mysql-8.0.34

cp -a ./support-files/mysql.server /etc/init.d/mysql
#授权以及添加服务

 

chmod +x /etc/init.d/mysql

chkconfig --add mysql


7、启动MySQL

systemctl start mysql

#查看启动状态

systemctl status mysql

#将mysql命令添加到服务
ln -s /usr/local/mysql-8.0/bin/mysql /usr/bin


8、登录MySQL

mysql -uroot -p 密码使用之前随机生成的密码

mysql -uroot -p

操作记录

mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 8

Server version: 8.0.34

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


9、修改root密码

这里有两种方式可以实现:

第一种:

[root\@mysql-server \~]# mysql -uroot -p'woHtkMgau9,w'   #登录

mysql: \[Warning] Using a password on the command line interface can be insecure.

    Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.27

....

mysql> alter user 'root'@'localhost' identified by 'Yang\@123';

Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;     //刷新权限表

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye

\[root\@mysql-server \~]# mysql -uroot -p'Yang\@123'

mysql: \[Warning] Using a password on the command line interface can be insecure.

    Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.27 MySQL Community Server (GPL)

...

mysql> exit

Bye


第二种:

mysqladmin -u root -p'旧密码' password '新密码'

注意:修改密码必须包含大小写字母、数字和特殊符号元素,长度不能小于8位。


10、修改远程链接并生效

#进入到mysql


use mysql;

update user set host='%' where user='root';

flush privileges;


CRMEB产品圈定期更新分享

👇👇欢迎关注【CRMEB产品圈】👇👇

40b38202503121108146230.jpg



请登录后查看

CRMEB-官方发布 最后编辑于2025-10-14 17:53:00

快捷回复
回复
回复
回复({{post_count}}) {{!is_user ? '我的回复' :'全部回复'}}
排序 默认正序 回复倒序 点赞倒序

{{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level || item.bbs_level }}

作者 管理员 企业

{{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推荐': '推荐'}}
{{item.is_suggest == 1? '取消推荐': '推荐'}}
沙发 板凳 地板 {{item.floor}}#
{{item.user_info.title || '暂无简介'}}
附件

{{itemf.name}}

{{item.created_at}}  {{item.ip_address}}
打赏
已打赏¥{{item.reward_price}}
{{item.like_count}}
{{item.showReply ? '取消回复' : '回复'}}
删除
回复
回复

{{itemc.user_info.nickname}}

{{itemc.user_name}}

回复 {{itemc.comment_user_info.nickname}}

附件

{{itemf.name}}

{{itemc.created_at}}
打赏
已打赏¥{{itemc.reward_price}}
{{itemc.like_count}}
{{itemc.showReply ? '取消回复' : '回复'}}
删除
回复
回复
查看更多
打赏
已打赏¥{{reward_price}}
27
{{like_count}}
{{collect_count}}
添加回复 ({{post_count}})

相关推荐

快速安全登录

使用微信扫码登录
{{item.label}} 加精
{{item.label}} {{item.label}} 板块推荐 常见问题 产品动态 精选推荐 首页头条 首页动态 首页推荐
取 消 确 定
回复
回复
问题:
问题自动获取的帖子内容,不准确时需要手动修改. [获取答案]
答案:
提交
bug 需求 取 消 确 定
打赏金额
当前余额:¥{{rewardUserInfo.reward_price}}
{{item.price}}元
请输入 0.1-{{reward_max_price}} 范围内的数值
打赏成功
¥{{price}}
完成 确认打赏

微信登录/注册

切换手机号登录

{{ bind_phone ? '绑定手机' : '手机登录'}}

{{codeText}}
切换微信登录/注册
暂不绑定
CRMEB客服

CRMEB咨询热线 咨询热线

400-8888-794

微信扫码咨询

CRMEB开源商城下载 源码下载 CRMEB帮助文档 帮助文档
返回顶部 返回顶部
CRMEB客服