centos7:mysql-5.7.23安装(二进制安装)

mysql有二进制码安装,和源码编译安装(mysql5.5使用cmake安装,mysql5.7需要安装boost依赖安装),因为boost依赖安装麻烦,所以用二进制码安装

MySql 5.7.23安装

1.首先上MySql的官网下载  https://dev.mysql.com/downloads/mysql/

centos7:mysql-5.7.23安装(二进制安装)

选择源码包:

centos7:mysql-5.7.23安装(二进制安装)

1、 新建/usr/local/src目录,保存下载的各类安装包

mkdir /usr/local/src

2、切换到/usr/local/src 下

cd /usr/local/src

3、下载mysql5.7二进制包,解压到当前目录下

tar -zxvf mysql-5.7.23-linux-glibc2.5-x86_64.tar.gz

4.将解过的mysql5.7包移动到/usr/local/下并改名为mysql

mv mysql-5.7.23-linux-glibc2.5-x86_64 /usr/local/mysql

5.切换到/usr/local/mysql下

/usr/local/mysql

6.新增mysql用户,并禁止shell登陆

# groupadd mysql
#useradd -r -g mysql -s /sbin/nologin mysql

7.初始化mysql5.7数据库:

确认/data/mysql数据库文件夹是否存在,不存在则创建

# ./bin/mysqld --initialize --user=mysql --datadir=/data/mysql

a.注意生成的临时密码 Ed0fem1S(oH/

2018-08-30T02:03:43.986729Z 1 [Note] A temporary password is generated for root@localhost: Ed0fem1S(oH/

b.继续执行

# ./bin/mysql_ssl_rsa_setup --datadir=/data/mysql

8.复制配置文件并修改

注意,如果./support-files/my-default.cnf 没有这个文件,可以到网上去收一下这个文件的大致内容。

# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL. [mysqld] # 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 # These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = ..... # 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 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

a.复制主配置文件

# cp ./support-files/my-default.cnf /etc/my.cnf

b.修改 /etc/my.cnf 配置文件

    # vi /etc/my.cnf
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql //指定程序路径
datadir = /data/mysql //指定数据存放路径
port = 3306 //指定端口号
# server_id = .....
socket = /tmp/mysql.sock //指定sock文件

9.复制启动文件并修改相关参数

a.复制启动脚本文件到init.d下

cp ./support-files/mysql.server /etc/init.d/mysqld

b.修改启动脚本相关参数

    vi /etc/init.d/mysqld
basedir=/usr/local/mysql //指定程序路径
datadir=/data/mysql //指定数据存放路径

10.启动mysql服务,并查看服务启动状态

    # chkconfig --add mysqld //加入开机启动
# /etc/init.d/mysqld start //启动mysql服务
# ps aux |grep mysqld // 查看mysql进程
# netstat -ntlp | grep 3306 //查看3306端口监听情况

11.重置密码

a.使用初始化临时密码登陆

# /usr/local/mysql/bin/mysql -uroot -p'Ed0fem1S(oH/'

b.修改mysql登陆密码:mysql

    mysql> set password = password('mysql');
上一篇:开发模式)Note6)单例模式的实现


下一篇:CSS布局 两列布局之单列定宽,单列自适应布局思路