MySql 5.7 部署(以Centos7.5为例子)
1.准备rpm包
到https://dev.mysql.com/downloads/mysql/5.7.html该地址下载
mysql-community-libs-5.7.27-1.el7.x86_64.rpm
mysql-community-common-5.7.27-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm
mysql-community-client-5.7.27-1.el7.x86_64.rpm
mysql-community-server-5.7.27-1.el7.x86_64.rpm
mysql-community-devel-5.7.27-1.el7.x86_64.rpm
2.安装
-1.安装前必须先卸载系统自身携带的mysql组件,一般是mariadb ,使用命令rpm -qa | grep mariadb查看下是否存在,存在就卸载掉,不然会跟mysql5.7冲突
-2.将rpm包放到 /usr/local/page/目录,page自己命名的,用于放置rpm包以及其他安装包。
-3.执行命令开始
cd /usr/local/paga ---安装mysql程序
rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.27-1.el7.x86_64.rpm
systemctl start mysqld ---启动mysql
mkdir -p /data/mysql/data ---创建数据库配置路径目录
systemctl stop mysqld ---停止mysql
vi /etc/my.cnf ---修改添加以下内容:
----------------------------------
datadir=/data/mysql/data
socket=/data/mysql/data/mysql.sock
skip_host_cache
skip-name-resolve=1
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_ALL_TABLES,NO_AUTO_CREATE_USER
lower_case_table_names=1
validate_password_policy=0
validate_password_length=4
[client]
socket=/data/mysql/data/mysql.sock
----------------------------------
cp -r /var/lib/mysql/* /data/mysql/data/
chown -R mysql:mysql /data/mysql/data/*
chown -R mysql:mysql /data/mysql/data
systemctl start mysqld ---启动mysql
grep "password" /var/log/mysqld.log ##查看临时密码
mysql -uroot -p临时密码 ##登录进去
alter user 'root'@'localhost' identified by '123456;
set @@GLOBAL.sql_mode="ONLY_FULL_GROUP_BY,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";
use mysql;
update mysql.user set authentication_string=password('123456') where user='root' and host='root' or host='localhost';
FLUSH PRIVILEGES;
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
FLUSH PRIVILEGES;
3.使用
执行以上步骤,基本安装完毕,命令行使用mysql -uroot -p123456
网友评论