rpm安装mysql5.7
搜狐mysql源
https://mirrors.sohu.com/mysql/MySQL-5.7/
下载对应的rpm依赖
https://mirrors.sohu.com/mysql/MySQL-5.7/mysql-community-client-5.7.37-1.el7.x86_64.rpm
https://mirrors.sohu.com/mysql/MySQL-5.7/mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm
https://mirrors.sohu.com/mysql/MySQL-5.7/mysql-community-server-5.7.37-1.el7.x86_64.rpm
https://mirrors.sohu.com/mysql/MySQL-5.7/mysql-community-common-5.7.37-1.el7.x86_64.rpm
https://mirrors.sohu.com/mysql/MySQL-5.7/mysql-community-libs-5.7.37-1.el7.x86_64.rpm
安装
rpm -ivh mysql-community-common-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.37-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.37-1.el7.x86_64.rpm
修改默认密码
systemctl start mysqld
grep "password" /var/log/mysqld.log
set global validate_password_policy = LOW;
set global validate_password_length = 9 ;
alter user user( ) identified by "ztl123456" ;
set global validate_password_length = 6 ;
alter user user( ) identified by "123456" ;
mysqladmin -uroot -p
yum安装mysql
yum install mariadb-server mariadb
systemctl start maria
二进制安装mysql
基本操作步骤
1 . 安装基础依赖
2 . 准备mysql多实例,各个配置文件3306 3307
3 . 准备各个启停管理脚本
4 . 修改目录权限
5 . 修改环境变量
5 . 数据初始化,生成mysql的初始化data数据
安装基础依赖
yum install ncurses-devel libaio-devel gcc make cmake
编写配置文件(my.cnf)
[ client]
[ mysqld]
user = mysql
port = 3306
socket = /data/mysql5.7/mysql/3306/mysql.sock
basedir = /data/mysql5.7/mysql-5.7.36-linux-glibc2.12-x86_64
datadir = /data/mysql5.7/mysql/3306/data
log-bin= /data/mysql5.7/mysql/3306/mysql-bin
server-id= 1
[ mysqld_safe]
log-error= /data/mysql5.7/mysql/3306/mysql_3306_error.log
pid-file= /data/mysql5.7/mysql/3306/mysqld_3306.pid
编写mysql的启停脚本
port = 3306
mysql_user = "root"
Cmdpath = "/data/mysql5.7/mysql-5.7.36-linux-glibc2.12-x86_64"
mysql_sock = "/data/mysql5.7/mysql/${port} /mysql.sock"
mysqld_pid_file_path = /data/mysql5.7/mysql/${port} /mysqld_${port} .pid
start ( ) {
if [ ! -e "mysql_sock" ] ; then
printf "Starting mysql...\n "
/bin/sh ${Cmdpath} /mysqld_safe --defaults-file= /data/mysql5.7/mysql/${port} /my.cnf --pid-file= $mysqld_pid_file_path 2 >&1 > /dev/null &
sleep 3
else
printf "mysql is running...\n "
exit 1
fi
}
restart ( ) {
printf "restarting mysql...\n "
stop
sleep 2
start
}
case "$1 " in
start)
start
; ;
stop)
stop
; ;
restart)
restart
; ;
*)
printf "usage: /mysql/${prot} /mysql{start|stop|restart}\n "
esac
修改目录权限并设置环境变量
chown -R mysql.mysql /data/mysql5.7/mysql
vim /etc/profile
export PATH = /data/mysql5.7/mysql-5.7.36-linux-glibc2.12-x86_64/bin/:$PATH
初始化数据
/data/mysql5.7/mysql-5.7.36-linux-glibc2.12-x86_64/bin/mysqld --defaults-file= /data/mysql5.7/mysql/3306/my.cnf --basedir = /data/mysql5.7/mysql-5.7.36-linux-glibc2.12-x86_64/ --datadir = /data/mysql5.7/mysql/3306/data --initialize --user = mysql