如果安装异常,修改Redhat的镜像源:
方法一:
{
cd /etc/yum.repos.d
mv redhat.repo redhat.repo-backup
下载一份源文件进行修改,移至目录下 /etc/yum.repos.d/CentOS7-
Base-163.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
cp CentOS7-Base-163.repo /etc/
替换 $releasever 为版本号 7.9.2009 ,替换好的文件内如如下:
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-7.9.2009 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?
release=7.9.2009&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-7.9.2009 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?
release=7.9.2009&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
2/9#additional packages that may be useful
[extras]
name=CentOS-7.9.2009 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?
release=7.9.2009&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7.9.2009 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7.9.2009/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
保存退出后,执行如下指令:
mv CentOS7-Base-163.repo redhat.repo
yum clean all
yum makecache
}
方法2:
{
1、修改红帽的订阅管理配置文件,再删除官方订阅
修改红帽的订阅管理配置文件:
cd /etc/yum/pluginconf.d/
vim subscription-manager.conf
将enabled的参数改为0,然后保存退出。
删除官方订阅:
yum remove subscription-manager
2、重新配置 redhat.repo文件
(1)为方便操作,先删除/etc/yum.repos.d目录下的 redhat.repo文件(如果没有就不用管)
(2)在/etc/yum.repos.d目录下,用vim编辑redhat.repo文件。将下面这段代码直接复制进去,然后保存退出
[AppStream]
name=AppStream
baseurl=http://mirrors.aliyun.com/almalinux/9.2/AppStream/x86_64/os/
gpgcheck=0
enabled=1
[BaseOS]
name=BaseOS
baseurl=http://mirrors.aliyun.com/almalinux/9.2/BaseOS/x86_64/os/
gpgcheck=0
enabled=1
[extras]
name=extras
baseurl=http://mirrors.aliyun.com/almalinux/9.2/extras/x86_64/os/
gpgcheck=0
enabled=1
[plus]
name=plus
baseurl=http://mirrors.aliyun.com/almalinux/9.2/plus/x86_64/os/
gpgcheck=0
enabled=1
[devel]
name=devel
baseurl=http://mirrors.aliyun.com/almalinux/9.2/devel/x86_64/os/
gpgcheck=0
enabled=1
[NFV]
name=NFV
baseurl=https://mirrors.aliyun.com/almalinux/9.2/NFV/x86_64/os/
gpgcheck=0
enabled=1
[CRB]
name=CRB
baseurl=https://mirrors.aliyun.com/almalinux/9.2/CRB/x86_64/os/
gpgcheck=0
enabled=1
[HighAvailability]
name=HighAvailability
baseurl=https://mirrors.aliyun.com/almalinux/9.2/HighAvailability/x86_64/os/
gpgcheck=0
enabled=1
3.执行下面命令
yum clean all
yum makecache
4、执行命令
yum install ncurses-libs
yum install ncurses-devel
yum install libncurses*
}
5
、查看版本
mysql --version
mysql Ver 14.14 Distrib 5.7.28, for Linux (x86_64) using EditLine
wrapper
,
如果出现该提示,则证明
mysql
已经安装成功了。
6
、启动
mysql
服务
==
每次开机都要手动启动
mysql ==
systemctl start mysqld
==
开机时自动开启
mysql ==
systemctl enable mysqld
3/9
==
停止
mysql
服务器
==
service mysqld stop
==
启动
mysql
服务器
==
service mysqld start
==
查看
mysql
是否启动
==
service mysqld status
7
、登录
mysql
mysql -u root -p
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using
password: YES)
提示错误,是因为第一次登录
mysql
需要使用
mysql
的临时密码,
该密码存放在
mysql
日志文件中。在
/var/log/mysqld.log
文件中
cd /var/log
查询临时密码
grep -n password mysqld.log
[Note] A temporary password is generated for root@localhost:
0x(g<n074&7W
0x(g<n074&7W
就是
mysql
自动生成的临时密码
重新登录
mysql
,隐式登录
mysql -u root -p
把临时密码粘贴
如果出现
mysql>
则登录成功
8
、修改密码
mysql> set global validate_password_policy=LOW;
mysql> set global validate_password_length=4;
4/9
mysql> alter user ‘root’@‘localhost’ identified by ‘
你自己得
mysql
密码
’;
9
、配置
mysql
远程访问
此时,虽然防火墙是关着的,但
root
用户只能用于本机访问,不能用于远
程访问,
否则会报错误。如果
navicat
想远程连接,是无法连接的
因此,接下来要做的是授予
root
用户远程访问权限
mysql> update mysql.user set host=‘%’ where user=‘root’;
mysql> flush privileges;
输入完以上命令后就可以使用连接工具连接到该
linux
的
mysql
了。
10
、修改编码
为了防止以后出现乱码问题,我们需要把
mysql
的编码修改为
utf8
[root@localhost mysql]# vim /etc/my.cnf || vi /etc/my.cnf