当前位置:   article > 正文

mysql三种安装方式 你知道了哪种_processing dependency: mysql-community-libs(x86-64

processing dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: my

安装mysql服务

  • mysql安装方式有三种:
  • 源代码:编译安装
    二进制格式的程序包:展开至特定路径,并经过简单配置后即可使用程序包管理器管理的程序包:rpm:有两种OS Vendor:操作系统发行商提供的项目官方提供的deb

yum 安装

  1. [root@localhost ~]# ls /etc/yum.repos.d/
  2. redhat.repo xx.repo
  3. [root@localhost ~]# rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
  4. 获取http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
  5. 警告:/var/tmp/rpm-tmp.pSGnsG: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
  6. 准备中... ################################# [100%]
  7. 正在升级/安装...
  8. 1:mysql57-community-release-el7-10 ################################# [100%]
  9. [root@localhost ~]# ls /etc/yum.repos.d/
  10. mysql-community.repo mysql-community-source.repo redhat.repo xx.repo

  1. [root@localhost ~]# yum -y install mysql-community-server mysql-community-client mysql-community-common mysql-community-devel
  2. Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-
  3. : manager
  4. This system is not registered with an entitlement server. You can use subscription-manager to register.
  5. Loading mirror speeds from cached hostfile
  6. Resolving Dependencies
  7. --> Running transaction check
  8. ---> Package mysql-community-client.x86_64 0:5.7.23-1.el7 will be installed
  9. --> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.23-1.el7.x86_64
  10. ....
  11. Installed:
  12. mysql-community-client.x86_64 0:5.7.23-1.el7
  13. mysql-community-common.x86_64 0:5.7.23-1.el7
  14. mysql-community-devel.x86_64 0:5.7.23-1.el7
  15. mysql-community-libs.x86_64 0:5.7.23-1.el7
  16. mysql-community-libs-compat.x86_64 0:5.7.23-1.el7
  17. mysql-community-server.x86_64 0:5.7.23-1.el7
  18. Replaced:
  19. mariadb-libs.x86_64 1:5.5.56-2.el7
  20. Complete!

启动mysql服务就ok

  1. [root@localhost ~]# systemctl start mysqld
  2. [root@localhost ~]# systemctl status mysqld

二进制安装mysql

-下载mysql二进制安装包

  1. wget https://downloads.mysql.com/archives/get/file/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz

-创建用户和组

  1. [root@localhost ~]# groupadd -r mysql
  2. [root@localhost ~]# useradd -M -s /sbin/nologin -g mysql mysql
  3. [root@localhost ~]#
  • 解压软件至/usr/local/
  1. [root@localhost ~]# tar -xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz -C /usr/l
  2. ocal/
  • 创建软连接
  1. [root@localhost ~]# cd /usr/local/
  2. [root@localhost local]# ln -s mysql-5.7.22-linux-glibc2.12-x86_64/ mysql
  3. [root@localhost local]#
  • 修改目录/usr/local/mysql的属组属组
  1. [root@localhost local]# cd
  2. [root@localhost ~]# chown -R mysql.mysql /usr/local/mysql*
  3. [root@localhost ~]#

-添加环境变量

  1. [root@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
  2. [root@localhost ~]# . /etc/profile.d/mysql.sh 重新读下
  3. [root@localhost ~]#
  • 建立数据存放目录
  1. [root@localhost ~]# mkdir /opt/data
  2. [root@localhost ~]# chown -R mysql.mysql /opt/data/
  3. [root@localhost ~]#
  • 初始化数据库
  1. [root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data
  2. 2019-08-20T04:36:47.124341Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  3. 2019-08-20T04:36:47.512965Z 0 [Warning] InnoDB: New log files created, LSN=45790
  4. 2019-08-20T04:36:47.568170Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  5. 2019-08-20T04:36:47.710963Z 0 [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: 1ee4d515-c304-11e9-bd54-000c292184e7.
  6. 2019-08-20T04:36:47.711625Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  7. 2019-08-20T04:36:47.712295Z 1 [Note] A temporary password is generated for root@localhost: *!J3wNVfewsf #复制这串密码,数据库初始化只能一次,用于第一次登录
  8. [root@localhost ~]# #这个临时密码是随机的
  • 生成配置文件
  1. [root@localhost ~]# cat > /etc/my.cnf <<EOF
  2. > [mysqld]
  3. > basedir = /usr/local/mysql
  4. > datadir = /opt/data
  5. > socket = /tmp/mysql.sock
  6. > port = 3306
  7. > pid-file = /opt/data/mysql.pid
  8. > user = mysql
  9. > skip-name-resolve
  10. > EOF
  11. [root@localhost ~]# cat /etc/my.cnf
  12. [mysqld]
  13. basedir = /usr/local/mysql
  14. datadir = /opt/data
  15. socket = /tmp/mysql.sock
  16. port = 3306
  17. pid-file = /opt/data/mysql.pid
  18. user = mysql
  19. skip-name-resolve

-配置服务启动脚本

  1. [root@localhost ~]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
  2. [root@localhost ~]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
  3. [root@localhost ~]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld
  • 启动脚本
  1. [root@localhost ~]# /etc/init.d/mysqld start
  2. Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
  3. SUCCESS!
  4. [root@localhost ~]#
  • 使用临时密码登录
  • 修改数据库密码
  1. [root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 2
  5. Server version: 5.7.22
  6. Copyright (c) 2000, 2018, 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> set password = password('wyh123456');
  12. Query OK, 0 rows affected, 1 warning (0.00 sec)
  13. mysql>

编译安装(源码安装)

  • 下载、上传源码安装包
  1. wget http://downloads.mysql.com/archives/get/file/mysql-5.7.26.tar.gz
  2. (https://downloads.mysql.com/archives/手动下载,上传)
  3. 下载
  • 安装依赖工具
  1. [root@localhost ~]# yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
  2. 安装过程省略……
  3. [root@localhost ~]#

下载cmake编译工具

  1. [root@localhost ~]# cd /usr/src/
  2. [root@localhost src]wget http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
  3. 下载过程略。。。
  4. [root@localhost src]# ls
  5. cmake-2.8.12.1.tar.gz

解压

  1. [root@localhost src]# tar xf cmake-2.8.12.1.tar.gz
  2. [root@localhost src]# ls
  3. cmake-2.8.12.1 cmake-2.8.12.1.tar.gz

编译安装cmake

  1. [root@localhost ~]# cd /usr/src/cmake-2.8.12.1
  2. [root@localhost cmake-2.8.12.1]# ./configure && make && make install

编译安装mysql5.7.26

  1. [root@localhost cmake-2.8.12.1]# cd /usr/src/
  2. [[root@localhost src]wget http://downloads.mysql.com/archives/get/file/mysql-5.7.26.tar.gz
  3. [[root@localhost src]# ls
  4. cmake-2.8.12.1 cmake-2.8.12.1.tar.gz kernels mysql-5.7.26.tar.gz
  5. [root@localhost src]# tar xf mysql-5.7.26.tar.gz
  6. [root@localhost src]# cd mysql-5.7.26
  7. [root@96 mysql-5.7.26]# cmake \
  8. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
  9. -DMYSQL_DATADIR=/usr/local/mysql/data \
  10. -DSYSCONFDIR=/etc \
  11. -DWITH_MYISAM_STORAGE_ENGINE=1 \
  12. -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  13. -DWITH_MEMORY_STORAGE_ENGINE=1 \
  14. -DWITH_READLINE=1 \
  15. -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
  16. -DMYSQL_TCP_PORT=3306 \
  17. -DENABLED_LOCAL_INFILE=1 \
  18. -DWITH_PARTITION_STORAGE_ENGINE=1 \
  19. -DEXTRA_CHARSETS=all \
  20. -DDEFAULT_CHARSET=utf8 \
  21. -DDEFAULT_COLLATION=utf8_general_ci \
  22. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/src/mysql-5.7.26/include/boost_1_59_0/patches/boost
  23. 编译过程略.....
  24. [root@local mysql-5.7.26]# make && make install

创建mysql用户和组

  1. [root@local mysql-5.7.26]# groupadd mysql
  2. [root@local mysql-5.7.26]# useradd -M -s /sbin/nologin -g mysql mysql

####、 设置环境变量

  1. [root@local mysql]# cd /usr/local/mysql/
  2. [root@local mysql]# echo 'export PATH=/usr/local/mysql/bin:$PATH' >/etc/profile.d/mysql.sh
  3. [root@local mysql]# . /etc/profile.d/mysql.sh

初始化数据库

  1. [root@local mysql]# mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
  2. 2019-08-17 17:29:43 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
  3. 2019-08-17 17:29:45 [WARNING] The bootstrap log isn't empty:
  4. 2019-08-17 17:29:45 [WARNING] 2019-08-17T09:29:43.936116Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
  5. 2019-08-17T09:29:43.936687Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
  6. 2019-08-17T09:29:43.936692Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

修改配置文件

  1. [root@local mysql]# sed -i '11,13d' /etc/my.cnf
  2. [root@local mysql]# sed -ri 's#^(datadir=).*#\1/usr/local/mysql/data#g' /etc/my.cnf
  3. [root@local mysql]# sed -ri 's#^(socket=).*#\1/tmp/mysql.sock#g' /etc/my.cnf

设置服务启动脚本

  1. [root@local mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
  2. [root@local mysql]sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
  3. [root@local mysql]# sed -ri 's#^(datadir=).*#\1/usr/local/mysql/data#g' /etc/init.d/mysqld

启动服务

  1. [root@local mysql]# service mysqld start
  2. Starting MySQL.Logging to '/usr/local/mysql/data/96.err'.
  3. SUCCESS!
  4. [root@local mysql]# chkconfig mysqld on
  5. [root@local mysql]# ss -antl
  6. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  7. LISTEN 0 128 *:111 *:*
  8. LISTEN 0 128 *:22 *:*
  9. LISTEN 0 80 :::3306 :::*
  10. LISTEN 0 128 :::111 :::*
  11. LISTEN 0 128 :::22

如果感觉小编写得不错,请素质三连:点赞+转发+关注。我会努力写出更好的作品分享给大家。更多JAVA进阶学习资料小编已打包好,可以关注私信找我领取哦

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Li_阴宅/article/detail/988608
推荐阅读
相关标签
  

闽ICP备14008679号