1.下载安装包(rpm下载)
1.1 下载地址的前缀是: wget http://dev.mysql.com/get/
1.2 后面拼接安装包名称即可Down MySQL Yum Repository

1.3 将名称拼接后完整下载命令是:
https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
1.4 mysql-5.7地址:
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2.yum安装(yum repository)
2.1 安装下载过来的文件:yum -y install mysql57-community-release-el7-10.noarch.rpm
2.2 yum安装mysql yum -y install mysql-community-server
2.3 启动mysql: service mysqld start
2.4 查看是否启动成功:service mysqld status
出现以下标准则代表启动成功

2.5 查看初始密码:
grep "password" /var/log/mysqld.log
2.6 进入数据库:
mysql -uroot -p
这里到-p就行了,回车会提示你输入密码的
2.7 修改初始密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
注意密码需要有大小写字母数字2.8 授权root账号远程登录:
grant all on *.* to root@'%' identified by '新密码';
2.9 mysql 重要目录说明:
#(a)数据库目录
/var/lib/mysql/
#(b)配置文件
/usr/share /mysql(mysql.server命令及配置文件)
#(c)相关命令
/usr/bin(mysqladmin mysqldump等命令)
#(d)启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
mysql配置文件: /etc/my.cnf
3.下载安装包方式rpm-tar(5.7)
3.1.下载rmp tar文件
5.7.22
版本号可以更改为指定的
5.7.22:wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-
5.7.22-1.el7.x86_64.rpm-bundle.tar
5.7.30:wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-
5.7.30-1.el7.x86_64.rpm-bundle.tar
3.2.解压:tar -xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
得到:

3.3 查看已安装的mysql:
rpm -qa|grep mysql
如图:

3.4 查看mariadb:
rpm -qa|grep mariadb
//rpm 删除指定包
rpm -e --nodeps 包名
如:rpm -e --nodeps mysql-community-common-5.7.30-1.el7.x86_64
//安装指定包
rpm -ivh 包
如:rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm
3.5 配置参考2.5
步骤一致,my.cnf
文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
log-bin=mysql-bin #开启二进制日志
server-id=31 #设置server-id
binlog-ignore-db=information_schema
binlog-ignore-db=cluster
binlog-ignore-db=mysql
binlog-do-db=imm
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
explicit_defaults_for_timestamp=true
character_set_server=utf8
init_connect='SET NAMES utf8'
lower_case_table_names=1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
validate_password_policy=0
validate_password = off
max_connections=1000
网友评论