centos 7.3 mysql5.7 安装

1,到官网下载安装包:
https://www.mysql.com/
这里写图片描述
这里写图片描述
2, 安装:

[root@master /opt/bigdata/service]# rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-common-5.7.22-1.e################################# [100%]

[root@master /opt/bigdata/service]# rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-libs-5.7.22-1.el7################################# [100%]
[root@master /opt/bigdata/service]# rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-client-5.7.22-1.e################################# [100%]
[root@master /opt/bigdata/service]# rpm -ivh mysql-community-server-
mysql-community-server-5.7.22-1.el7.x86_64.rpm          mysql-community-server-minimal-5.7.22-1.el7.x86_64.rpm  
[root@master /opt/bigdata/service]# rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm 
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql-community-server-5.7.22-1.e################################# [100%]

3, 初始化密码:

[root@master /opt/bigdata/service]# mysqld --initialize --user=mysql
[root@master /opt/bigdata/service]# cat cat /var/log/mysqld.log | grep password
cat: cat: No such file or directory
2018-05-28T13:03:28.527740Z 1 [Note] A temporary password is generated for root@localhost: 0wEeI2ylfm?.

4, 启动mysql修改密码:

systemctl start mysqld.service

[root@master /opt/ClusterBuildScripts]# mysql -u root -p
Enter password: (输入3中得到的初始化密码:)
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22

Copyright (c) 2000, 2018, 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 clear the current input statement.

mysql> set password = password('12345678');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all privileges on *.* to 'root' @'%' identified by  'yourpassword';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

5, mysql 启动和停止相关命令


centos  默认启动方式:
systemctl start mysqld.service

启动:

使用 service 启动:service mysqld start
使用 mysqld 脚本启动:/etc/inint.d/mysqld start
使用 safe_mysqld 启动:safe_mysqld&
停止:

使用 service 启动:service mysqld stop
使用 mysqld 脚本启动:/etc/inint.d/mysqld stop
mysqladmin shutdown 
重启:

使用 service 启动:service mysqld restart
使用 mysqld 脚本启动:/etc/inint.d/mysqld restart

6, mysql 自启动:

[root@master /]# systemctl list-unit-files | grep mysql 
mysqld.service                                enabled 
mysqld@.service                               disabled
[root@master /]# 

centos 默认自启动
可以进行取消:
systemctl disable mysqld

然后在/etc/rc.local
先执行systemctl start mysqld
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值