centos8安装mysql
2022/7/7 2:20:17
本文主要是介绍centos8安装mysql,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
0、软件版本
VMware16 CentOS8.2 MySQL:5.5.58.rpm包
1、检测本机安装的MySQL
rpm -qa|grep -i mysql
2、卸载mysql
rpm -e rpm包 yum -y remove mysql* 如果卸载不掉,mysql可直接换成检测到的包名 rm -rf /var/lib/mysql rm /etc/my.cnf
3、安装mysql
1.安装MySQL-server
[root@centos8 linux_mysql]# rpm -ivh MySQL-server-5.5.58-1.el6.x86_64.rpm --force --nodeps 警告:MySQL-server-5.5.58-1.el6.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY Verifying... ################################# [100%] 准备中... ################################# [100%] 正在升级/安装... 1:MySQL-server-5.5.58-1.el6 ################################# [100%] 220706 20:41:34 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 220706 20:41:34 [Note] /usr/sbin/mysqld (mysqld 5.5.58) starting as process 33380 ... 220706 20:41:34 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 220706 20:41:34 [Note] /usr/sbin/mysqld (mysqld 5.5.58) starting as process 33387 ... PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h centos8 password 'new-password' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. Please report any problems at http://bugs.mysql.com/
2.安装mysql-client
[root@centos8 linux_mysql]# rpm -ivh MySQL-client-5.5.58-1.el6.x86_64.rpm --force --nodeps 警告:MySQL-client-5.5.58-1.el6.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY Verifying... ################################# [100%] 准备中... ################################# [100%] 正在升级/安装... 1:MySQL-client-5.5.58-1.el6 ################################# [100%] [root@centos8 linux_mysql]#
查看Mysql安装时创建的mysql用户和mysql组
[root@centos8 linux_mysql]# cat /etc/passwd|grep mysql mysql:x:975:973:MySQL server:/var/lib/mysql:/bin/bash [root@centos8 linux_mysql]# [root@centos8 linux_mysql]# cat /etc/group|grep mysql mysql:x:973: [root@centos8 linux_mysql]#
查看mysql版本
[root@centos8 linux_mysql]# mysqladmin --version mysqladmin Ver 8.42 Distrib 5.5.58, for Linux on x86_64
4、MySQL 默认没有密码,需要使用mysqladmin设置密码
/usr/bin/mysqladmin -u root password '新密码'
5、启动mysql并设置自启动
systemctl start mysqld.server
systemctl stop mysqld.server
systemctl enable mysqld.server 设置开机自启动
6、防火墙开通3306端口
[root@centos8 ~]# firewall-cmd --add-port=3306/tcp --permanent success [root@centos8 ~]#
报错
重置密码时提示/usr/bin/mysqladmin: 没有那个文件或目录
原因:yum安装GPG keys ,不安装的话 安装mysql rpm包时要加 --force --nodeps
启动mysql服务时失败
systemctl status mysql.service 查看服务状态 --》 有报错 没有权限
ps -ef | grep mysql 查看服务权限
解决:关闭selinux,重新启动
vim /etc/sysconfig/selinux 设置为disabled
这篇关于centos8安装mysql的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-16MySQL资料:新手入门教程
- 2024-11-15MySQL教程:初学者必备的MySQL数据库入门指南
- 2024-11-15MySQL教程:初学者必看的MySQL入门指南
- 2024-11-04部署MySQL集群项目实战:新手入门教程
- 2024-11-04如何部署MySQL集群资料:新手入门指南
- 2024-11-02MySQL集群项目实战:新手入门指南
- 2024-11-02初学者指南:部署MySQL集群资料
- 2024-11-01部署MySQL集群教程:新手入门指南
- 2024-11-01如何部署MySQL集群:新手入门教程