为什么要写这个呢,是因为我太好忘了,偏偏我的服务器都是centos的,每次都要找好久,算是个笔记吧

在这里介绍使用yum安装mysql

你可能要准备的软件包

yum install -y wget

第一步:找到yum的下载地址,不过这个并不好找(mysql网站是英文的),不过的他也是有yum仓库的

yum库地址

列举部分下载地址

https://repo.mysql.com/mysql57-community-release-el5-7.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el5-8.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el5.rpm
https://repo.mysql.com/mysql57-community-release-el6-10.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el6-11.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el6-7.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el6-8.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el6-9.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el6.rpm
https://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el7-7.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
https://repo.mysql.com/mysql57-community-release-el7.rpm

我们挑一个进行安装,我喜欢这个mysql57-community-release-el7-10.noarch.rpm

  1. 命令下载

    wget https://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm

  2. 安装yum库

    yum -y install mysql57-community-release-el7-10.noarch.rpm

  3. 安装mysql服务

    yum -y install mysql-community-server

  4. 启动mysql

    systemctl start mysqld.service

  5. 查看mysql运行状态

    systemctl status mysqld.service

  6. 查看随机密码

    grep "password" /var/log/mysqld.log

  7. 使用随机密码登录mysql

    mysql -uroot -p

  8. 修改数据库密码,不修改无法操作数据库,请注意密码默认是8位大小写字母加数字和特殊符号(是必须)

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

  9. 你也可以查看一下密码策略

    show variables like '%password%';

至此mysql数据库安装完成,你可能还需要mysql远程访问、基本操作
update user set host = '%' where user = 'root';
flush privileges;
exit

MySQL教程 - 菜鸟教程


本文由 就是吃不胖 创作,采用 知识共享署名 3.0,可自由转载、引用,但需署名作者且注明文章出处。

还不快抢沙发

添加新评论