MySQLrpm包安装以及基础设置

目录

一、MYSQL安装

二、创建数据库school,字符集为utf-8

三、在school数据库中创建student和score表如下图:​编辑​编辑1.创建student表:create table student (id int(10) not null unique auto_increment,name varchar(20) notnull,sex varchar(4),birth year,department varchar(20) not null,address varchar(50),primary key (id));​编辑

四、授权用户tom,密码Mysql@123,能够从任何地方登录并管理数据库school。

五、使用mysql客户端登录服务器,重置root密码                                                                                                                               


一、MYSQL安装

1.检查自己计算机是否有gcc /gcc-c++编译器,如果没有要使用:yum install gcc gcc-c++ make -y 命令来下载基础的编译器

2.下载并安装MySQL rpm包 3.启动MySQL服务和设置开机自启动

4.启动MySQL和获得临时密码在我们第一次登陆时需要使用MySQL给的临时密码来登录 

5.更改密码

二、创建数据库school,字符集为utf-8

mysql> create database school character set utf8;

三、在school数据库中创建student和score表如下图:1.创建student表:create table student (id int(10) not null unique auto_increment,name varchar(20) notnull,sex varchar(4),birth year,department varchar(20) not null,address varchar(50),primary key (id));

2.创建score表:mysql> create table score (id int(10) not null unique auto_increment, stu_id int(10) not null,c_name varchar(20),grade int(10),primary key (id));

四、授权用户tom,密码Mysql@123,能够从任何地方登录并管理数据库school。

1.创建tom用户:mysql> create user 'tom' @'%' identified by 'Mysql@123';
2.授权:mysql> grant all on *.* to 'tom'@'%' with grant option;

五、使用mysql客户端登录服务器,重置root密码                                                                                                                               

mysql版本 5.6 5.7  8.0
方法一:mysql版本 5.6 5.7  8.0
#mysqladmin -uroot -p'旧密码' password 新密码;
5.6版本
mysqladmin password 新密码;直接将初始化密码改为新密码
方法二:mysql版本 5.7  8.0
>alter user 'root'@localhost identified by '新密码';使用该方法用户信息全部加密
或者
>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
方法三:mysql 5.6  5.7
>set password for root@localhost=password('新密码');
方法四:8.0 5.6  5.7
8.0
mysql> update mysql.user set authentication_string='Mysql@123' where user='root';
5.7
update mysql.user set authentication_string=password('新密码') where user='root';
>flush privileges;
5.6
mysql> update user set password=password('新密码') where user='root' and host='localhost';
>flush privileges;

        

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

哈hhhh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值