下载地址 https://downloads.mysql/archives/community/
#1 下载解压移动
wegt https://downloads.mysql/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/myf
[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/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/myf
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
更多推荐
mysql 5.7.24 二进制安装
发布评论