源码安装mysql
参考:
https://www.cnblogs.com/Amos-Turing/p/17126265.html
https://blog.csdn.net/xcjyxy2021/article/details/124376407
https://blog.csdn.net/sinat_20260363/article/details/128922998
前言
1.在下面网站找到需要安装的mysql版本
https://downloads.mysql.com/archives/community/
注意要选择的操作系统为linux-generic
2.kafka安装方式链接有空可测试下:https://blog.csdn.net/m0_46192647/article/details/123424090
一. mysql部署
systemctl stop firewalld && setenforce 0
#下载安装包
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
groupadd -r mysql
useradd -M -r -s /sbin/nologin -g mysql mysql
tar zxvf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
cd /usr/local/
mv mysql-5.7.36-linux-glibc2.12-x86_64 mysql
chown -R mysql.mysql /usr/local/mysql
vim /etc/profile.d/mysql.sh
添加export PATH=/usr/local/mysql/bin:$PATH
source /etc/profile.d/mysql.sh
echo $PATH
#检查:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
mkdir -p /data/mysql
chown -R mysql.mysql /data/mysql
ll -d /data/mysql
二. 初始化数据库
mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql
cat > /etc/my.cnf << EOF
[mysqld]
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/data/mysqld.pid
symbolic-links=0
max_connections=10000
max_connect_errors=10000
max_allowed_packet=128M
innodb_file_per_table=ON
innodb_buffer_pool_size=1G
innodb_log_file_size=128M
innodb_open_files=1024
table_open_cache=4096
skip-name-resolve
event_scheduler=ON
#查询缓存,根据业务需要是看否需要
query_cache_type=ON
query_cache_size=64M
EOF
chown -R mysql:mysql /etc/my.cnf
touch /var/log/mysqld.log
chmod 755 /var/log/mysqld.log
chown -R mysql:mysql /var/log/mysqld.log
cat >> /usr/lib/systemd/system/mysqld.service << EOF
[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为mysql安装路径
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
EOF
systemctl daemon-reload
systemctl enable mysqld
systemctl start mysqld
三. 修改临时密码
mysql -uroot -p #使用初始化时的临时密码登录
#改密
alter user 'root'@'localhost' identified by 'Gioneco@2021';
#授权navicat登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Gioneco@2021' WITH GRANT OPTION;
flush privileges ;
#登录mysql可能会报兼容错误
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
#参考https://www.cnblogs.com/Amos-Turing/p/17126163.html
ln -s /usr/lib64/libncurses.so.6 /usr/lib64/libncurses.so.5
ln -s /usr/lib64/libtinfo.so.6 /usr/lib64/libtinfo.so.5
努力生活,融于自然
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步