CentOS 7.9 RPM安装Mysql数据库过程

CentOS 7.9 RPM安装Mysql数据库过程

1.查看系统版本

cat /etc/redhat-release

2.下载mysql 的安装文件

下载地址 https://downloads.mysql.com/archives/community/

3.检查服务器上是否安装mysql

 rpm -qa | grep mysql        查看
 rpm -e --nodeps  文件名字    卸载
 卸载旧版本mariadb
 rpm -qa|grep mariadb #查找mariadb
 rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64 #卸载

4. 安装mysql所需要的依赖 ,如果不安装后面执行rpm可能会报错

yum -y install libaio
yum -y install net-tools
yum -y install perl

5.rpm 执行顺序(严格按照这个顺序执行)

        rpm -ivh mysql-community-common-5.7.36-1.el7.x86_64.rpm
        rpm -ivh mysql-community-libs-5.7.36-1.el7.x86_64.rpm
        rpm -ivh mysql-community-client-5.7.36-1.el7.x86_64.rpm
        rpm -ivh mysql-community-server-5.7.36-1.el7.x86_64.rpm
        rpm -ivh mysql-community-devel-5.7.36-1.el7.x86_64.rpm

记得修改my.cnf

6. 启动MySQL

service mysqld start

7.查看临时密码

grep password /var/log/mysqld.log

8.修改密码

用查看的临时密码去登录数据库
mysql -uroot –p
修改密码
set password for root@localhost=password(‘aniu@123’);

9.配置数据库远程链接

mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
mysql>exit;

大功告成!!!

你可能感兴趣的:(数据库,mysql,centos)