centos mysql 二进制_Centos7 Mysql5.7.27二进制安装

步骤一:下载安装包,打开Mysql官网,找到对应的

wget https://downloads.mysql.com/archives/get/file/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz -O /usr/local/src/mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz

dd795149ea734f60a1f6a9c5ba1aba55.png

步骤二:下载依赖包,Centos7自带不需要安装

[root@centos702 21:56:19]:/usr/local/src

#yum -y installlibaio

已加载插件:fastestmirror, langpacks

Loading mirror speeds from cached hostfile*base: mirrors.aliyun.com*epel: mirrors.aliyun.com*extras: mirrors.aliyun.com*updates: mirrors.aliyun.com

软件包 libaio-0.3.109-13.el7.x86_64 已安装并且是最新版本

无须任何处理

步骤三:解压安装包

[root@centos702 21:58:45]:/usr/local/src

#tar -zxvf mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz

步骤四:创建数据库用户,移动数据库文件到你想要放的位置,并创建mysql数据目录,最后修改属主为Mysql

[root@centos702 21:59:26]:/usr/local/src

#useradd-M -s /sbin/nologin -r mysql

#mv /usr/local/src/mysql-5.7.27-linux-glibc2.12-x86_64 /home/data/mysql

[root@centos70222:02:09]:/usr/local/src

#mkdir -p /home/data/mysql

[root@centos70222:02:18]:/usr/local/src

#chown -R mysql.mysql /home/data/mysql

步骤五:初始化数据库

[root@centos702 22:04:56]:/home/data

#/home/data/mysql/bin/mysqld --initialize --user=mysql --basedir=/home/data/mysql --datadir=/home/data/mysql/data2019-11-09T14:06:56.634380Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for moredetails).2019-11-09T14:06:57.063698Z 0 [Warning] InnoDB: New log files created, LSN=45790

2019-11-09T14:06:57.142365Z 0[Warning] InnoDB: Creating foreign key constraint system tables.2019-11-09T14:06:57.200813Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 30cc7a37-02fa-11ea-a548-000c29cbc202.2019-11-09T14:06:57.202254Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed'cannot be opened.2019-11-09T14:06:57.203612Z 1 [Note] A temporary password is generated for root@localhost: KaELVb2yol<4 #此次是生成的临时密码,用于第一次登陆,登陆后需要重新修改

步骤六:创建配置文件,这里只创建常见配置文件

cat > /etc/my.cnf <

[mysqld]

basedir=/home/data/mysql

datadir=/home/data/mysql/data

port=3306socket=/home/data/mysql/mysql.sock

character-set-server=utf8

log-error=/var/log/mysqld.log

pid-file=/tmp/mysqld.pid

[mysql]

socket=/home/data/mysql/mysql.sock

[client]

socket=/home/data/mysql/mysql.sock

EOF

步骤七:配置环境变量,并刷新

cat >/etc/profile.d/mysql.sh <

export PATH=/home/data/mysql/bin:\$PATH

EOF

source /etc/profile.d/mysql.sh

步骤八:生成启动脚本,并启动mysql

[root@centos702 22:14:40]:/home/data

#cp /home/data/mysql/support-files/mysql.server /etc/init.d/mysql

[root@centos70222:16:42]:/home/data

#chmod +x /etc/init.d/mysql

[root@centos702 22:17:55]:/home/data

#vim /etc/init.d/mysql

#修改mysql启动配置文件,指定datadir和basedir路径,如不指定,默认是/usr/local/mysql

[root@centos70222:18:31]:/home/data

#sed -i '46s#basedir=#basedir=/home/data/mysql#' /etc/init.d/mysql

[root@centos70222:20:15]:/home/data

#sed -n '46p' /etc/init.d/mysql

basedir=/home/data/mysql

[root@centos70222:20:30]:/home/data

#sed -i '47s#datadir=#datadir=/home/data/mysql/data#' /etc/init.d/mysql

[root@centos70222:21:13]:/home/data

#sed -n '47p' /etc/init.d/mysql

datadir=/home/data/mysql/data

#启动mysql

[root@centos70222:23:54]:/home/data

#/etc/init.d/mysql start

Starting MySQL. SUCCESS!

步骤九:登录mysql,并修改密码

[root@centos702 22:26:28]:/home/data

#mysql-uroot -p'KaELVb2yol<4'mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connectionid is 3Server version:5.7.27Copyright (c)2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c' to clearthe current input statement.

mysql> set password for root@localhost=password('cnhope');

Query OK,0 rows affected, 1 warning (0.00sec)

mysql>flush privileges;

Query OK,0 rows affected (0.00 sec)

68f724bad5a33d9a9f6bd2ca7369ecb7.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值