Linux-mysql编译安装步骤
安装mysql
用wget下载
cd /server/tools/
wget http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
解压缩
tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
规范安装目录
mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql-5.7.26
ln -s /application/mysql-5.7.26 /application/mysql
清除mariadb数据库
rpm -e --nodeps mariadb-libs
配置my.cnf文件
vim /etc/my.cnf
[mysqld]
basedir = /application/mysql/
datadir = /application/mysql/data
socket = /tmp/mysql.sock
server_id = 1
port = 3306
log_error = /application/mysql/data/oldboy_mysql.err
[mysql]
socket = /tmp/mysql.sock
prompt = oldboy [\\d]>
安装依赖包
yum install libaio-devel -y
创建mysql用户
useradd mysql -s /sbin/nologin -M
mkdir -p /application/mysql/data
chown -R mysql.mysql /application/mysql/
编译安装
/application/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data
配置mysql服务文件
cat >/etc/systemd/system/mysqld.service <<poi
[Unit]
Description=MySQL Server by oldboy
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=/application/mysql/bin/mysqld -- defaults-file=/etc/my.cnf
LimitNOFILE = 5000
poi
开启mysql服务
systemctl start mysqld
systemctl status mysqld
添加环境变量
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
. /etc/profile
安装完成
- 设置数据库密码
mysqladmin -u root password 'xxxxxxxx'
菜鸟9528号,请求开炮。