mysql二进制包、YUM安装

二进制包安装
下载二进制包
#wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

解压包
#tar zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz


安装库文件
#yum install libaio

移动目录
#mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql

移动到/usr/local/mysql
#cd /usr/local/mysql

添加用户
#useradd -M -s /sbin/nologin mysql

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

目录所属组改为mysql用户
#chown -R mysql .

创建目录
#mkdir /var/run/mysqld

更改目录权限
#chown mysql /var/run/mysqld


创建配置文件
#vi my.conf
[mysqld]
daemonize = on
user = mysql
port = 3306
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
socket = /tmp/mysql.sock
pid-file = /var/run/mysqld/mysqld.pid
character-set-server = utf8
collation-server = utf8_general_ci
max_connections = 1024
log-error = /usr/local/mysql/mysqld.log



system管理mysql
#vi /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

[Service]
User=mysql
Group=mysql
Type=forking
TimeoutSec=0
PermissionsStartOnly=true
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/usr/local/mysql/etc/my.conf
LimitNOFILE=5000
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false

[Install]
WantedBy=multi-user.target




#systemctl start mysqld  启动mysql服务
#systemctl status mysqld
#systemctl stop mysqld
查看监听端口
#netstat -antp | grep 3306


进入数据库
#bin/mysql -uroot -p


修改密码
#ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';   #后面一定要加分号


设置开机启动
#systemctl enable mysqld



# 下载mysql源安装包  官网默认8.0YUM源
在这个网站下载: http://dev.mysql.com/downloads/repo/yum/ 
rpm -Uvh mysql80-community-release-el7-1.noarch.rpm


下载5.7 YUM源
#wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

安装yum源
#rpm -Uvh mysql57-community-release-el7-8.noarch.rpm

yum安装
#yum install mysql-community-server

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值