Centos7安装mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz(安装步骤)


[html]  view plain  copy
  1. <code class="language-html">安装MySQL 5.7.20  
  2. shell> cd /usr/local  
  3. shell> groupadd mysql  
  4. shell> useradd -g mysql mysql  
  5. shell> tar xzvf mysql-5.7.20-linux-glibc2.12-x86_64.tar.gz  
  6. shell> cd mysql-5.7.20-linux-glibc2.12-x86_64  
  7.   
  8. # 这里注意了,以前的版本是有一个my.cnf文件,这个版本不要这个了  
  9. # 如果存在就把它删除吧,否则会出现各种错误  
  10. shell> rm -rf /etc/my.cnf  
  11.   
  12. shell> cd /usr/local  
  13. shell> ln -s mysql-5.7.20-linux-glibc2.12-x86_64 mysql  
  14. shell> cd /usr/local/mysql  
  15. shell> chown -R mysql .  
  16. shell> chgrp -R mysql .  
  17. shell> mkdir /usr/local/mysql/data  
  18. shell> /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data  
  19. # 出现以下几个[Warning]不用管它,只要没有[ERROR] 就是安装成功了  
  20. [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).  
  21. [Warning] InnoDB: New log files created, LSN=45790  
  22. [Warning] InnoDB: Creating foreign key constraint system tables.  
  23. [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: a4d71248-c432-11e7-8eab-00163e002e4a.  
  24. [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.  
  25. [Note] A temporary password is generated for root@localhost: =MqLUlnme6hh  
  26.   
  27. # 注意了,上面最后一行产一个随机密码,冒号后面的都是密码,我的密码则是=MqLUlnme6hh  
  28. # 这个随机密码第一次登录的时候需要用到  
  29.   
  30. shell> chown -R root .  
  31. shell> chown -R mysql data  
  32. # 启动MySQL  
  33. shell> cd /usr/local/mysql  
  34. shell> bin/mysqld_safe --user=mysql &  
  35.   
  36.   
  37. # 登录并更改密码  
  38. shell> /usr/local/mysql/bin/mysql -uroot -p  
  39. # 这时提示输入password,输入上面的随机密码  
  40. # 用随机密码登录后,必须要更改密码,否则不能进行任何操作,更改密码:  
  41. mysql> SET PASSWORD = PASSWORD('newpasswd');  
  42. mysql> exit;  
  43.   
  44. # 关闭MySQL服务  
  45. shell> /usr/local/mysql/bin/mysqladmin -u root -p shutdown  
  46. shell> Enter password:  
  47. # 输入密码回车就关闭数据库  
  48.   
  49.   
  50. # 编辑PATH搜索路径  
  51. shell> vi /etc/profile  
  52.   
  53. # 在profile文件末尾增加两行  
  54. PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH  
  55. export PATH  
  56.   
  57. # 使PATH搜索路径立即生效:  
  58. shell> source /etc/profile  
  59.   
  60. # 开机自动启动:  
  61. shell> cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql  
  62. shell> chkconfig --add mysql  
  63.   
  64. # 手动启动:以root身份执行:  
  65. shell> /usr/local/mysql/bin/mysqld_safe --user=mysql &  
  66.   
  67. #赋予root用户所有权限,远程登录密码是123456  
  68. grant all privileges on *.* to 'root' @'%' identified by '123456';  
  69.   
  70. #开放3306端口并重启防火墙  
  71. firewall-cmd --permanent --add-port=3306/tcp  
  72. firewall-cmd --reload</code>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值