centos 7.0下安装MySQL 5.7.26

1.下载MySQL 5.7.26安装包

centos 7.0下安装MySQL 5.7.26

 

2.上传MySQL 5.7.26安装包,并解压,创建软连接

gunzip mysql5.7.26linuxglibc2.12x86_64.tar.gz

tar -xvf mysql-5.7.26-linux-glibc2.12-x86_64.tar 

ln -s /stage/mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql

3.添加用户组,用户,创建目录,修改相关目录权限

groupadd mysql

useradd -g mysql mysql

chown -R mysql.mysql /usr/local/mysql*

mkdir -p /data/3306/datadir

mkdir -p /data/3306/binlog

chown -R mysql.mysql /data*

4.修改profile

vi /etc/profile

export PATH=/usr/local/mysql/bin:$PATH

source /etc/profile

5.初始化

mysqld ‐‐initializeinsecure ‐‐user=mysql ‐‐basedir=/usr/local/mysql ‐‐datadir=/data/3306/data

6.修改配置文件

vi /etc/my.cnf

[mysqld]
user=mysql
basedir=/usr/local/mysql
datadir=/data/3306/data
log_bin=/data/3306/binlog/mysql‐bin
port=3306
server_id=7
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock

7.准备启动脚本

cd /usr/local/mysql/supportfiles/

cp /usr/local/mysql/supportfiles/mysql.server  /etc/init.d/mysqld

vi /etc/init.d/mysqld

basedir=/usr/local/mysql
datadir=/data/3306/data

/etc/init.d/mysqld start

8.修改密码

方法一:mysqladmin -uroot -p password

方法二:alter user root@localhost identified by ‘mysql‘;

centos 7.0下安装MySQL 5.7.26

上一篇:mysql


下一篇:[db2数据库同步]db2数据库同步