centos7 安装mysql 根据官网文档

  1. 总体,下载mysql资源库,安装mysql资源库,yum中设置mysql版本,安装mysql
  2. https://dev.mysql.com/doc/refman/5.7/en/linux-installation-yum-repo.html  官网网站
  3. https://dev.mysql.com/downloads/repo/yum/  中选择centos版本官网网站
  4. 下载  wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm(我的centos 7 ,先点击下载,然后在不了谢谢处直接复制链接,下载80 好,因为你可以安装5.5 5.6 5.7 8 这三个版本)
  5. https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm  centos 6
  6. 安装资源  yum localinstall mysql80-community-release-el7-3.noarch.rpm
  7. 查看 默认版本 yum repolist enabled | grep "mysql.*-community.*" 
  8. 查看所有可用版本 yum repolist all | grep mysql
  9. 修改默认版本 vim /etc/yum.repos.d/mysql-community.repo  (要安装的版本下设置 enabled=1 其他的版本 =0)
  10. 安装 yum install mysql-community-server
  11. systemctl start mysqld  启动
  12. 设置密码 关闭数据库服务  systemctl stop mysqld
  13. vim  vim /etc/my.cnf  添加 这行 skip-grant-tables  跳过登录的验证  就是没有密码也能登上 在启动数据库服务
  14. mysql -uroot -p  登录数据库 提示密码时 直接回车键  use mysql
  15. update user set authentication_string =password('123456'),password_expired='N' where user='root'; 设置密码
  16. 注意mysql5。7 密码的字段的 authentication_string 以前的版本是 password 
  17. flush privileges ; 刷新
  18. grant all privileges on *.* to 'root'@'%'identified by '123456' with grant option;  授权 所以用户可登录
  19. 刷新 
  20. vim  vim /etc/my.cnf  注释 这行 skip-grant-tables
  21. 重启 ok
  22. centos6安装默认5.1
  23. yum install mysql-server
    service mysqld restart
    mysql
    show databases;
    use mysql;
    show tables;
    desc mysql;
    grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
    delete from user where host!='%';
    service mysqld restart 或者里面 flush privileges;
    /etc/my.cnf 的[mysqld]下添加skip-name-resolve即可
  24. # 卸载
    service mysqld stop
    yum remove mysql mysql-* -y
    rpm -qa | grep mysql
    yum list installed | grep mysql
  25. centos6 安装5.7 
  26. wget https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm
  27. yum localinstall mysql80-community-release-el6-3.noarch.rpm -y
  28. 按照9操作
  29. yum install mysql-community-server
  30. 启动有时会报错
  31. cd /var/lib/mysql
    rm -rf ./*
  32. service mysqld restart
  33. service mysqld stop
  34. vim /etc/my.cnf 添加 skip-grant-tables 保存退出重启 
  35. mysql -uroot
  36. use mysql
  37. grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
  38. update user set password=password("123456") where user="root";
    delete from user where host!='%';flush privileges;
  39. quit 
  40. 去掉  vim /etc/my.cnf   skip-grant-tables
    service mysqld restart
  41. ok
  42. skip-name-resolve
  43. 5.7 安装不成功,5.6 一次安装成功,
  44. 5.6授权
  45. grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
  46. select HOST,user,authentication_string from user;
  47. update user set authentication_string =password('123456'),password_expired='N' where user='root';
  48. delete from user where host!='%';flush privileges;
  49. skip-name-resolve
  50. rpm -qa | grep mysql 查看是否安装
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值