linux中的mysql安装

解决mysql yum 源

登录MySQL :: Download MySQL Yum Repository

点击Download

鼠标右键点击下方蓝体复制链接

yum install wget

wget https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm

rpm -ivh mysql80-community-release-el7-7.noarch.rpm

或者-

rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm

yum makecache

更换mysql 版本8.0 更换为5.7

打开 vi mysql-community.repo

# Enable to use MySQL 5.7

[mysql57-community]

name=MySQL 5.7 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]

name=MySQL 8.0 Community Server

baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

更改为

# Enable to use MySQL 5.7

[mysql57-community]

name=MySQL 5.7 Community Server

baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

       file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]

name=MySQL 8.0 Community Server

baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

       file:///etc/pki/rppg/RPM-GPG-KEY-mysql

yum clean all

yum makecache

1)

直接安装的是客户端  

yum install mysql

指定安装服务端

yum install mysql-community-server

查看mysql状态

systemctl status mysqld

启动mysql

systemctl start mysqld

查看密码

[root@Centos7 ~]# cat /var/log/mysqld.log | grep pass

2023-07-03T05:28:53.476463Z 1 [Note] A temporary password is generated for root@localhost: h6ydFv#dWWTd

1)必须重置密码

mysql> set password = password('Aaa!@#123'); #设置当前用户密码

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

更新鉴权

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

忘记密码修改密码

1、修改配置文件my.cnf,使mysql 5.7 无需输入密码直接登录

我的操作系统里面,my.cnf的路径在 /etc/my.cnf。进入该文件:

vi /etc/my.cnf

然后在尾部添加行skip-grant-tables,保存之后退出来,然后重新启动一下mysql,使用命令为:

/etc/init.d/mysqld restart

2、登录mysql,修改密码

使用命令mysql -u root登录到mysql里面,然后就可以修改root的密码

mysql>use mysql;

mysql>update user set authentication_string = password(‘new_password’) where user = ‘root’ and Host = ‘localhost’;

3、修改配置文件my.cnf,注释skip-grant-tables,然后重启mysql。使用的命令如下:

vi /etc/my.cnf #注释skip-grant-tables

/etc/init.d/mysqld restart #重新启动mysql

4、使用新的密码登录root

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值