yum方式安装mysql
安装步骤
1. 安装yum仓库
到https://dev.mysql.com/downloads/repo/yum/ 下载对应操作系统版本的yum仓库,然后进行安装:sudo rpm -Uvh platform-and-version-specific-package-name.rpm
2. 选择需要安装的mysql版本
默认情况下,在上一步安装的yum仓库中激活的是最新版本的MySQL,例如现在最新版本的MySQL是5.7,如下:
shell> yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 42
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 55
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 247
mysql57-community-source MySQL 5.7 Community Server - S disabled
mysql80-community/x86_64 MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - S disabled
如果确实需要安装最新版的MySQL,那么不需要做任何修改。
如果现在需要安装的是MySQL5.6而不是最新版的5.7,那么需要执行如下操作:
shell> sudo yum-config-manager --disable mysql57-community
shell> sudo yum-config-manager --enable mysql56-community
如果报错-bash: um-config-manager: command not found
,则先执行:sudo yum -y install yum-utils
。
现在再来看激活的版本是什么: 显然是5.6版本的MySQL。
shell> yum repolist all | grep mysql
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 42
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community/x86_64 MySQL Tools Community enabled: 55
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community/x86_64 MySQL 5.6 Community Server enabled: 378
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community/x86_64 MySQL 5.7 Community Server disabled
mysql57-community-source MySQL 5.7 Community Server - S disabled
mysql80-community/x86_64 MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - S disabled
3. 执行安装
shell> sudo yum install mysql-community-server
4. 启动MySQL
shell> sudo service mysqld start
启动成功之后就可以连接MySQL服务器了,使用root用户的登录不需要密码。
shell> mysql -uroot -p
当然,登录成功之后可以修改root密码:
mysql> update user set Password=password('!Q111111') where User='root';
注意,这种方式修改的root密码需要重启MySQL服务之后才能生效。
【参考】
https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
https://blog.csdn.net/moxiaomomo/article/details/9792801 【MySQL】查看MySQL配置文件路径及相关配置
https://www.cnblogs.com/gaowengang/p/10816537.html Ubuntu 18.04 安装配置 MySQL 5.7
https://www.cnblogs.com/ycyzharry/p/11678494.html CentOS6.9安装MySQL5.6
https://blog.csdn.net/weixin_41641738/article/details/119853713 centos8 安装MySql社区版服务报错 Error: Unable to find a match: mysql-community-server
https://www.jianshu.com/p/91f282efde37 MySQL8.0安装之后查找默认密码
https://blog.csdn.net/qq_23859799/article/details/85862821 mysql8.0数据库添加用户和授权
作者:编程随笔
出处:http://www.cnblogs.com/nuccch/
声明:本文版权归作者和博客园共有,欢迎转载,但请在文章页面明显位置给出原文连接。