一些机子上会自带mysql,可以把它们检索出来并且删除掉,不然后面操作会出错。
# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
个人习惯,新建文件夹单独存放
# mkdir /usr/local/mysql
# cp -a /root/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar /usr/local/mysql
# ll /usr/local/mysql
总用量 823252
-rw-r–r--. 1 root root 843008000 2月 28 16:09 mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
解压到对应的目录
# tar -xf /usr/local/mysql/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar -C /usr/local/mysql
删除 c p过去的包
# rm -f /usr/local/mysql/mysql-8.0.28-1.el7.x86_64.rpm-bundle.tar
效果
# ls /usr/local/mysql
mysql-community-client-8.0.28-1.el7.x86_64.rpm
mysql-community-embedded-compat-8.0.28-1.el7.x86_64.rpm
mysql-community-server-8.0.28-1.el7.x86_64.rpm
mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
mysql-community-test-8.0.28-1.el7.x86_64.rpm
mysql-community-common-8.0.28-1.el7.x86_64.rpm
mysql-community-libs-8.0.28-1.el7.x86_64.rpm
mysql-community-devel-8.0.28-1.el7.x86_64.rpm
mysql-community-libs-compat-8.0.28-1.el7.x86_64.rpm
说明
In most cases, you need to install the mysql-community-server, mysql-community-client, mysql-community-libs, mysql-community-common, and mysql-community-libs-compat packages to get a functional, standard MySQL installation. To perform such a standard, basic installation, go to the folder that contains all those packages (and, preferably, no other RPM packages with similar names)
翻译:在大多数情况下,您需要安装 MySQL-community-server、 MySQL-community-client、 MySQL-community-libs、 MySQL-community-common 和 MySQL-community-libs-compat 包,以获得一个功能性的标准 MySQL 安装。要执行这种标准的基本安装,请转到包含所有这些包的文件夹(最好是没有其他具有类似名称的 RPM 包)
依次运行 - - 安装
# rpm -ivh --nodeps /usr/local/mysql/mysql-community-server-8.0.28-1.el7.x86_64.rpm # rpm -ivh --nodeps /usr/local/mysql/mysql-community-client-8.0.28-1.el7.x86_64.rpm # rpm -ivh --nodeps /usr/local/mysql/mysql-community-libs-8.0.28-1.el7.x86_64.rpm # rpm -ivh --nodeps /usr/local/mysql/mysql-community-common-8.0.28-1.el7.x86_64.rpm # rpm -ivh --nodeps /usr/local/mysql/mysql-community-libs-compat-8.0.28-1.el7.x86_64.rpm
如果出现警告
/usr/local/mysql/mysql-community-server-8.0.28-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
这是由于yum安装了旧版本的GPG keys造成的,从 RPM 版本 4.1 开始,在安装或升级软件包时会检查软件包的签名。在每条安装命令后面加上:
--force --nodeps
–nodeps就是忽视依赖关系
# ll /var/lib/mysql
新安装的mysql都会随机生成一个root的密码用来登录。
查看密码:
# cat /var/log/mysqld.log
可以看到默认密码:bOaA-Kj36bum
启动服务
# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
登录
# mysql -u root -p
输入的密码就是上面的默认密码,由于安全起见输入密码的时候不会有任何显示。
修改密码:
mysql> alter user 'root'@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec)
初次进入需要修改密码才能继续使用mysql,注意sql语法,后面的英文分号
退出:
mysql> \q
Bye
# mysql -V
mysql Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)
由于防火墙的缘故,需要开启相应的端口号(默认3306)或者关闭防火墙(极其不推荐)来实现远程连接。
方法 - - 直达快车
然后链接就好了
查看环境
# mysql -V
mysql Ver 8.0.28 for Linux on x86_64 (MySQL Community Server - GPL)
完结撒花