二进制安装Mysql-5.7
1安装流程
Step1下载软件
创建下载目录并下载mysql二进制包,可以通过wget下载的方式下载,也可以离线通过lrzsz工具上传至软件下载目录。
mkdir -p /server/tools && cd /server/tools
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
Step2解压软件
通过tar命令解压mysql软件
tar zxf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
创建软件安装目录,将解压后的软件移到软件安装目录
mkdir /application
mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql
Step3环境配置
删除mysql原始安装软件
yum remove mariadb-*
创建mysql用户
useradd -s /sbin/nologin mysql
设置mysql环境变量
vim /etc/profile
export PATH=/application/mysql/bin:$PATH
source /etc/profile
创建数据存储路径并授权
mkdir /data /mysql/data -p
chown -R mysql.mysql /application/mysql/*
chown -R mysql.mysql /data/mysql
初始化mysql
mysqld --initialize --user=mysql --basedir=/application/mysql --datadir=/data/mysql/data
Step4配置文件修改
创建临时配置文件
cat >/etc/my.cnf <<EOF
[mysqld]
user=mysql
basedir=/application/mysql
datadir=/data/mysql/data
socket=/tmp/mysql.sock
server_id=6
port=3306
[mysql]
socket=/tmp/mysql.sock
EOF
Step5创建service方式启动文件
[root@mysql01 mysql]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@mysql01 mysql]# service mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.Logging to ‘/data/mysql/data/mysql01.err‘.
SUCCESS!
Step6创建service方式启动文件
vim /lib/systemd/system/mysql.service
文件内容:
[Unit]
Description=mysql
After=network.target
[Service]
Type=forking
ExecStart=/application/mysql/support-files/mysql.server start
ExecStop=/application/mysql/support-files/mysql.server stop
ExecRestart=/application/mysql/support-files/mysql.server restart
ExecReload=/application/mysql/support-files/mysql.server reload
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Step7修改mysql密码
关闭数据库
/etc/init.d/mysqld stop
启动到数据库维护模式
mysqld_safe --skip-grant-tables --skip-networking &
登录并修改mysql密码
#mysql
mysql> alter user root@‘localhost‘ identified by ‘123456‘;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
mysql> alter user root@‘localhost‘ identified by ‘1‘;
mysql> flush privileges;
至此二进制安装mysql成功
相关文章
- 07-31Windows 8 下离线安装。net Framework 3.5
- 07-31mac 下安装securecrt
- 07-315 -- Hibernate的基本用法 --2 1 Hibernate 下载和安装
- 07-31VS2010 win7 64位安装后新建项目生成时错误:LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
- 07-31pip安装:Cannot uninstall ''. It is a distutils installed project and thus we cannot accurate
- 07-31python – 使用我自己的自定义二进制文件的NoSql?
- 07-31为多个OS X版本构建二进制python发行版
- 07-31【Python爬虫实战】Scrapy框架的安装 搬运工亲测有效
- 07-31二进制32位转十进制int
- 07-31冰蝎动态二进制加密WebShell特征分析