centos 7.4 yum安装mysql5.7

4 篇文章 0 订阅

 

mysql5.7安装

1.1  进入本机源文件目录/usr/local/src

# cd /usr/local/src/

1.2  wget mysql的rpm包

# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

1.3 运行rpm命令预编译

# rpm -ivh mysql57-community-release-el7-11.noarch.rpm
warning: mysql57-community-release-el7-11.noarch.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:mysql57-community-release-el7-11 ################################# [100%]
[root@iZ23hdndo4vZ src]# 

1.4 yum方式安装mysql-server

# yum install -y mysql-server

1.5  启动停止mysql服务命令

# systemctl start mysqld
# systemctl stop mysqld

1.6 查找初始密码

# cat /var/log/mysqld.log 
2018-09-19T06:43:48.776000Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-09-19T06:43:50.543804Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-09-19T06:43:50.754544Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-09-19T06:43:50.821659Z 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: 5e3cf68a-bbd7-11e8-86d0-00163e09c8b0.
2018-09-19T06:43:50.824047Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-09-19T06:43:50.824508Z 1 [Note] A temporary password is generated for root@localhost: /oCbd<c+4exw

初始密码为:/oCbd<c+4exw

1.7 进入mysql服务修改初始化的密码

# mysql -u root -p
Enter password:

设置修改的密码不做任务验证

mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

设置新的密码

mysql> alter user 'root'@'localhost' identified by '新的密码';

1.8 新建数据库,并新建用户,开通外网访问权限

创建数据库ds9

mysql> create database ds9;

创建两个用户

mysql> create user 'dianshi9'@'localhost' identified by '密码';
Query OK, 0 rows affected (0.00 sec)

mysql> create user 'ds9_select'@'%' identified by '密码';
Query OK, 0 rows affected (0.00 sec)

为数据库分配权限

给用户dianshi9分配ds9数据库的内网操作的所有权限

mysql> grant all privileges on ds9.* to 'dianshi9'@'localhost' identified by '密码';
Query OK, 0 rows affected, 1 warning (0.00 sec)

给用户ds9_select分配所有网络的select,insert,update操作权限

mysql> grant select,update,insert on ds9.* to 'ds9_select'@'%' identified by '密码';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;

完成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值