数据库
首页 > 数据库> > centos8安装mysql

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: 没有那个文件或目录

image
原因:yum安装GPG keys ,不安装的话 安装mysql rpm包时要加 --force --nodeps

启动mysql服务时失败

systemctl status mysql.service 查看服务状态 --》 有报错 没有权限

ps -ef | grep mysql 查看服务权限

image

解决:关闭selinux,重新启动

vim /etc/sysconfig/selinux
设置为disabled

image

标签:--,安装,mysql,server,MySQL,root,centos8
来源: https://www.cnblogs.com/jiyuchen1/p/16452651.html