• 售前

  • 售后

热门帖子
入门百科

centos7.3 安装mysql5.7.18的具体教程

[复制链接]
子非鱼JXX 显示全部楼层 发表于 2021-10-25 19:26:34 |阅读模式 打印 上一主题 下一主题
1查看Linux发行版本
[root@typecodes ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
2 下载MySQL官方的Yum Repository
根据Linux发行版本(CentOS、Fedora都属于红帽系),从mysql官方(http://dev.mysql.com/downloads/repo/yum/)获取Yum Repository。
  1. [root@typecodes ~]# wget -i http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
  2. --2016-02-03 18:36:02-- http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
  3. Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
  4. Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... connected.
  5. HTTP request sent, awaiting response... 302 Found
  6. Location: http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm [following]
  7. --2016-02-03 18:36:04-- http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
  8. Resolving repo.mysql.com (repo.mysql.com)... 104.102.164.25
  9. Connecting to repo.mysql.com (repo.mysql.com)|104.102.164.25|:80... connected.
  10. HTTP request sent, awaiting response... 200 OK
  11. Length: 8984 (8.8K) [application/x-redhat-package-manager]
  12. Saving to: ‘mysql57-community-release-el7-7.noarch.rpm'
  13. 100%[=============================================================================================================================>] 8,984  --.-K/s in 0s
  14. 2016-02-03 18:36:07 (68.4 MB/s) - ‘mysql57-community-release-el7-7.noarch.rpm' saved [8984/8984]
  15. 3 安装MySQL的Yum Repository
  16. 安装完MySQL的Yum Repository,每次执行yum update都会检查MySQL是否更新。
  17. [root@typecodes ~]# yum -y install mysql57-community-release-el7-7.noarch.rpm
  18. Loaded plugins: axelget, fastestmirror, langpacks
  19. Examining mysql57-community-release-el7-7.noarch.rpm: mysql57-community-release-el7-7.noarch
  20. Marking mysql57-community-release-el7-7.noarch.rpm to be installed
  21. Resolving Dependencies
  22. --> Running transaction check
  23. ---> Package mysql57-community-release.noarch 0:el7-7 will be installed
  24. --> Finished Dependency Resolution
  25. Dependencies Resolved
  26. =======================================================================================================================================================================
  27. Package          Arch      Version     Repository             Size
  28. =======================================================================================================================================================================
  29. Installing:
  30. mysql57-community-release      noarch      el7-7      /mysql57-community-release-el7-7.noarch      7.8 k
  31. Transaction Summary
  32. =======================================================================================================================================================================
  33. Install 1 Package
  34. Total size: 7.8 k
  35. Installed size: 7.8 k
  36. Downloading packages:
  37. Running transaction check
  38. Running transaction test
  39. Transaction test succeeded
  40. Running transaction
  41. Installing : mysql57-community-release-el7-7.noarch                            1/1
  42. Verifying : mysql57-community-release-el7-7.noarch                           1/1
  43. Installed:
  44. mysql57-community-release.noarch 0:el7-7
  45. Complete!
复制代码
3 安装MySQL数据库的服务器版本
  1. [root@typecodes ~]# yum -y install mysql-community-server
  2. Loaded plugins: axelget, fastestmirror, langpacks
  3. No metadata available for base
  4. No metadata available for epel
  5. No metadata available for extras
  6. repomd.xml                                  | 2.5 kB 00:00:00  
  7. update mysql-connectors-community metadata successfully
  8. repomd.xml                                  | 2.5 kB 00:00:00  
  9. update mysql-tools-community metadata successfully
  10. repomd.xml                                  | 2.5 kB 00:00:00  
  11. update mysql57-community metadata successfully
  12. No metadata available for updates
  13. mysql-connectors-community                              | 2.5 kB 00:00:00  
  14. mysql-tools-community                               | 2.5 kB 00:00:00  
  15. mysql57-community                                | 2.5 kB 00:00:00  
  16. (1/3): mysql-tools-community/x86_64/primary_db                         | 24 kB 00:00:01  
  17. (2/3): mysql57-community/x86_64/primary_db                          | 28 kB 00:00:01  
  18. (3/3): mysql-connectors-community/x86_64/primary_db                        | 8.6 kB 00:00:02  
  19. Loading mirror speeds from cached hostfile
  20. * base: mirrors.aliyun.com
  21. * epel: mirrors.neusoft.edu.cn
  22. * extras: mirrors.163.com
  23. * updates: mirrors.163.com
  24. Resolving Dependencies
  25. --> Running transaction check
  26. ---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed
  27. --> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
  28. --> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64
  29. --> Running transaction check
  30. ---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed
  31. --> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64
  32. ---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed
  33. --> Running transaction check
  34. ---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted
  35. --> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
  36. --> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64
  37. ---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting
  38. --> Running transaction check
  39. ---> Package mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 will be obsoleting
  40. --> Finished Dependency Resolution
  41. Dependencies Resolved
  42. =======================================================================================================================================================================
  43. Package           Arch       Version        Repository        Size
  44. =======================================================================================================================================================================
  45. Installing:
  46. mysql-community-libs        x86_64      5.7.10-1.el7       mysql57-community      2.2 M
  47.   replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
  48. mysql-community-libs-compat      x86_64      5.7.10-1.el7       mysql57-community      2.0 M
  49.   replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos
  50. mysql-community-server        x86_64      5.7.10-1.el7       mysql57-community      142 M
  51. Installing for dependencies:
  52. mysql-community-client        x86_64      5.7.10-1.el7       mysql57-community       24 M
  53. mysql-community-common        x86_64      5.7.10-1.el7       mysql57-community      269 k
  54. Transaction Summary
  55. =======================================================================================================================================================================
  56. Install 3 Packages (+2 Dependent packages)
  57. Total download size: 171 M
  58. Downloading packages:
  59. mysql-community-server-5.7.10-1.el7.x86_64.rpm                         | 142 MB 00:03:42  
  60. mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm                        | 2.0 MB 00:00:03  
  61. mysql-community-libs-5.7.10-1.el7.x86_64.rpm                         | 2.2 MB 00:00:05  
  62. mysql-community-client-5.7.10-1.el7.x86_64.rpm                         | 24 MB 00:00:41  
  63. warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA
  64. Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installed
  65. mysql-community-common-5.7.10-1.el7.x86_64.rpm                         | 269 kB 00:00:01  
  66. Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  67. Importing GPG key 0x5072E1F5:
  68. Userid  : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
  69. Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
  70. Package : mysql57-community-release-el7-7.noarch (@/mysql57-community-release-el7-7.noarch)
  71. From  : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  72. Running transaction check
  73. Running transaction test
  74. Transaction test succeeded
  75. Running transaction
  76. Installing : mysql-community-common-5.7.10-1.el7.x86_64                           1/6
  77. Installing : mysql-community-libs-5.7.10-1.el7.x86_64                           2/6
  78. Installing : mysql-community-client-5.7.10-1.el7.x86_64                           3/6
  79. Installing : mysql-community-server-5.7.10-1.el7.x86_64                           4/6
  80. Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64                          5/6
  81. Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                           6/6
  82. Verifying : mysql-community-server-5.7.10-1.el7.x86_64                           1/6
  83. Verifying : mysql-community-libs-compat-5.7.10-1.el7.x86_64                          2/6
  84. Verifying : mysql-community-common-5.7.10-1.el7.x86_64                           3/6
  85. Verifying : mysql-community-libs-5.7.10-1.el7.x86_64                           4/6
  86. Verifying : mysql-community-client-5.7.10-1.el7.x86_64                           5/6
  87. Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                           6/6
  88. Installed:
  89. mysql-community-libs.x86_64 0:5.7.10-1.el7   mysql-community-libs-compat.x86_64 0:5.7.10-1.el7   mysql-community-server.x86_64 0:5.7.10-1.el7
  90. Dependency Installed:
  91. mysql-community-client.x86_64 0:5.7.10-1.el7          mysql-community-common.x86_64 0:5.7.10-1.el7
  92. Replaced:
  93. mariadb-libs.x86_64 1:5.5.44-2.el7.centos
  94. Complete!
  95. [root@typecodes ~]# clear
复制代码
末了的截图:

4 启动数据库:
  1. [root@typecodes ~]# systemctl start mysqld.service
复制代码
然后使用下令
  1. systemctl status mysqld.service
复制代码
查看MySQL数据库启动后的服务状态:

5 获取初始暗码
使用YUM安装并启动MySQL服务后,MySQL历程会自动在历程日志中打印root用户的初始暗码:
  1. #######从mysql进程日志中获取root用户的初始密码:ra%yk7urCBIh
  2. [root@typecodes ~]# grep "password" /var/log/mysqld.log
  3. 2016-02-03T10:42:17.272166Z 1 [Note] A temporary password is generated for root@localhost: ra%yk7urCBIh
  4. 2016-02-03T10:42:36.776875Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
  5. 2016-02-03T10:42:52.063138Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
  6. 2016-02-03T10:42:57.564373Z 4 [Note] Access denied for user 'root'@'localhost' (using password: NO)
  7. 2016-02-03T10:43:01.477007Z 5 [Note] Access denied for user 'root'@'localhost' (using password: NO)
  8. 2016-02-03T10:46:03.642008Z 6 [Note] Access denied for user 'root'@'localhost' (using password: NO)
  9. 2016-02-03T10:46:11.217889Z 7 [Note] Access denied for user 'root'@'localhost' (using password: NO)
  10. 2016-02-03T10:47:44.755199Z 0 [Note] Shutting down plugin 'validate_password'
  11. 2016-02-03T10:47:46.505844Z 0 [Note] Shutting down plugin 'sha256_password'
  12. 2016-02-03T10:47:46.505851Z 0 [Note] Shutting down plugin 'mysql_native_password'
复制代码
6 修改root用户暗码
使用末节5中获取的root用户的初始暗码,然后举行修改:
  1. set global validate_password_policy =0
复制代码
;//默认是1,即MEDIUM,以是刚开始设置的暗码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。
  1. set global validate_password_length=4;//指定了密码中数据的长度
  2. alter user root@localhost identified by 'crow';//修改密码
复制代码
增长长途访问权限
  1. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'crow' WITH GRANT OPTION;
  2. FLUSH PRIVILEGES;
复制代码
退出mysql,然后重启服务
  1. systemctl restart mysqld
复制代码
防火墙打开3306端口
  1. firewall-cmd --zone=public --add-port=3306/tcp --permanent
复制代码
重启防火墙
  1. firewall-cmd --reload
  2. [root@typecodes ~]# mysql -uroot -p
  3. Enter password:    #######输入默认的root密码后回车
  4. Welcome to the MySQL monitor. Commands end with ; or \g.
  5. Your MySQL connection id is 2
  6. Server version: 5.7.10
  7. Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  8. Oracle is a registered trademark of Oracle Corporation and/or its
  9. affiliates. Other names may be trademarks of their respective
  10. owners.
  11. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  12. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
  13. Query OK, 0 rows affected (0.00 sec)
  14. mysql> exit
  15. Bye
复制代码
7 安装完毕
至此,使用在CentOS7中使用YUM方法安装MySQL5.7.10数据库完毕。如下所示,可以使用新的root暗码登陆MySQL了。
  1. [root@typecodes ~]# mysql -uroot -ppassword
  2. mysql: [Warning] Using a password on the command line interface can be insecure.
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 3
  5. Server version: 5.7.10 MySQL Community Server (GPL)
  6. Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  11. mysql> use mysql;
  12. Reading table information for completion of table and column names
  13. You can turn off this feature to get a quicker startup with -A
  14. Database changed
  15. mysql> show databases;
  16. +--------------------+
  17. | Database   |
  18. +--------------------+
  19. | information_schema |
  20. | mysql    |
  21. | performance_schema |
  22. | sys    |
  23. +--------------------+
  24. 4 rows in set (0.00 sec)
  25. mysql> clear
  26. mysql> exit
  27. Bye
  28. [root@typecodes ~]# clear
复制代码
附录1:查看MySQL数据库的设置信息
MySQL的设置文件依然是/etc/my.cnf,其它安装信息可以通过mysql_config下令查看。此中,动态库文件存放在/usr/lib64/mysql目次下。
  1. <img title="mysql_config命令查看mysql数据库的安装信息" alt="mysql_config命令查看mysql数据库的安装信息" src="https://img.jbzj.com/file_images/article/201706/201706061422437.png" />
复制代码

附录2:对于C/C++等开辟者
由于须要用到类似mysql.h等头文件,须要实行下面的下令安装mysql开辟版本即可。
  1. [root@typecodes ~]# yum -y install mysql-community-devel
复制代码
附录3:删除MySQL的Repository
由于末节3中安装了MySQL的Yum Repository,以是以后每次实行yum操作时,都会去查抄更新。假如想要去掉这种自动查抄操作的话,可以使用如下下令卸载MySQL的Repository即可。
  1. [root@typecodes ~]# yum -y remove mysql57-community-release-el7-7.noarch
  2. update 2017.04.10 11:10
复制代码
使用上面的yum方法也可以安装现在mysql官网上最新的版本mysql5.7.18。只要更换末节2中rmp包的版本即可,后续操作步调不变。
  1. wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
复制代码
以上所述是小编给各人先容的centos7.3 安装mysql5.7.18的具体教程,渴望对各人有所帮助,假如各人有任何疑问请给我留言,小编会及时复兴各人的。在此也非常感谢各人对草根技术分享网站的支持!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

帖子地址: 

回复

使用道具 举报

分享
推广
火星云矿 | 预约S19Pro,享500抵1000!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

草根技术分享(草根吧)是全球知名中文IT技术交流平台,创建于2021年,包含原创博客、精品问答、职业培训、技术社区、资源下载等产品服务,提供原创、优质、完整内容的专业IT技术开发社区。
  • 官方手机版

  • 微信公众号

  • 商务合作