首页 Linux

rpm方式安装Mysql

下载解压mysql

wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.38-1.el7.x86_64.rpm-bundle.tar -C mysql

卸载可能会冲突的软件包

yum erase -y mariadb-libs

开始安装Mysql
安装时可能会报错,看什么报错 就补装什么包, 比如 yum install net-tools

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

安装执行后就可以启动了
启动Mysql systemctl start mysqld
停止Mysql systemctl stop mysqld
重启Mysql systemctl restart mysqld
查看Mysql状态 systemctl status mysqld
设置开机自启 systemctl enable mysqld
禁用开机自启 systemctl disable mysqld
登陆mysql mysql -u root -p

另外 Msql安装后会生成一个随机密码在日志文件可以查看/var/log/mysqld.log
执行下面代码搜索

cat /var/log/mysqld.log | grep "temporary password"

1661954590947.jpg




文章评论