日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CentOS 7 MySql 解压版安装配置

發布時間:2023/12/15 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CentOS 7 MySql 解压版安装配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

下載

  • 訪問www.mysql.com
  • 點擊DOWNLOADS-->Community-->MySQL Community Server
  • 選擇要下載的版本,目前可選擇的有:5.5、5.6、5.7、8.0,這里以5.7為例,所以選擇的是5.7。
  • 操作系統選擇Red Hat Enterprise Linux / Oracle Linux,操作系統版本選擇Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit),下面列表過濾的找到Compressed TAR Archivetar壓縮文件下載即可,這里選擇的是mysql-5.7.25-el7-x86_64.tar.gz。
  • 將文件下載到CentOS服務器上,或者通過Windows下載后上傳到CentOS服務器上。

    (這里將文件放到/opt/soft/mysql-5.7.25-el7-x86_64.tar.gz)

    安裝配置

    1、添加組和用戶

    [root@localhost ~]: groupadd mysql [root@localhost ~]: useradd -r -g mysql mysql

    2、解壓到指定位置

    這里準備將mysql放到/opt/program/mysql目錄中。

  • 創建/opt/program/目錄。
  • 進入到/opt/program/目錄。
  • 解壓/opt/soft/mysql-5.7.25-el7-x86_64.tar.gz文件,不指定目錄的話,會解壓到用戶所在的目錄(也就是/opt/program/)。
  • 重新命名文件夾名為mysql。
  • 創建數據庫目錄data。
  • [root@localhost ~]: mkdir /opt/program [root@localhost ~]: cd /opt/program [root@localhost program]: tar -zxvf /opt/soft/mysql-5.7.25-el7-x86_64.tar.gz mysql-5.7.25-el7-x86_64/bin/myisam_ftdump mysql-5.7.25-el7-x86_64/bin/myisamchk mysql-5.7.25-el7-x86_64/bin/myisamlog mysql-5.7.25-el7-x86_64/bin/myisampack mysql-5.7.25-el7-x86_64/bin/mysql ………… [root@localhost program]: mv mysql-5.7.25-el7-x86_64 mysql [root@localhost program]: mkdir mysql/data

    3、給用戶和組賦權

    [root@localhost ~]: chown -R mysql:mysql /opt/program/mysql

    4、初始化mysql數據庫

    初始化需要指定mysql程序的目錄以及數據庫的目錄

    [root@localhost ~]: /opt/program/mysql/bin/mysqld --initialize --user=mysql --basedir=/opt/program/mysql --datadir=/opt/program/mysql/data 2019-03-16T14:28:52.317678Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-03-16T14:28:54.382317Z 0 [Warning] InnoDB: New log files created, LSN=45790 2019-03-16T14:28:54.699000Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2019-03-16T14:28:54.772198Z 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: d3d169f0-47f7-11e9-9ce7-000c291627c9. 2019-03-16T14:28:54.773910Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2019-03-16T14:28:54.775717Z 1 [Note] A temporary password is generated for root@localhost: hxwVZi*0-e3<

    警告可以先不管,最后的位置是隨機生成的root密碼hxwVZi*0-e3<

    5、配置my.cnf文件

    mysql啟動時,默認會查找/etc/my.cnf文件作為配置文件。

    [root@localhost ~]: vi /etc/my.cnf

    配置示例如下:

    [mysql] default-character-set=utf8[mysqld] lower_case_table_names=1 basedir=/opt/program/mysql datadir=/opt/program/mysql/data port=3306 character-set-server=utf8 max_connections=2000 innodb_buffer_pool_size=128M log-error=/opt/program/mysql/data/error.log pid-file=/opt/program/mysql/data/mysql.pid socket=/opt/program/mysql/mysql.sock

    6、為mysql配置環境變量

    可以通過/etc/profile文件配置。

    [root@localhost ~]: vi /etc/profile

    打開該文件,在最末尾的位置加上

    PATH=$PATH:/opt/program/mysql/bin

    保存退出,再執行

    [root@localhost ~]: source /etc/profile

    通過# echo $PATH可以查看環境變量信息

    7、制作自啟動服務

    第一種,將mysql.server復制到/etc/ini.d/目錄下配置自啟動服務

    [root@localhost ~]: cp /opt/program/mysql/support-files/mysql.server /etc/ini.d/mysql [root@localhost ~]: chmod +x /etc/ini.d/mysql [root@localhost ~]: chkconfig --add mysql

    通過# chkconfig --list查看是否添加成功

    然后通過service命令控制

    [root@localhost ~]: service mysql start

    第二種,通過systemd制作自啟動服務

    [root@localhost ~]: touch /etc/systemd/system/mysql.service [root@localhost ~]: vi /etc/systemd/system/mysql.service

    配置示例如下:

    [Unit] Description=mysql service[Service] Type=forking ExecStart=/opt/program/mysql/support-files/mysql.server start ExecStop=/opt/program/mysql/support-files/mysql.server stop User=mysql[Install] WantedBy=multi-user.target

    然后通過systemctl命令控制即可,啟動服務和啟用自啟動

    [root@localhost ~]: systemctl start mysql.service [root@localhost ~]: systemctl enable mysql.service

    第三種,通過systemd制作自啟動服務,并且通過mysql/bin/mysqld來啟動,my.cnf可以自定義位置。(參照于Windows服務的啟動配置)
    mysql.service配置示例如下:

    [Unit] Description=mysql service[Service] ExecStart=/opt/program/mysql/bin/mysqld --defaults-file=/opt/program/mysql/my.cnf --user=mysql User=mysql[Install] WantedBy=multi-user.target

  • 錯誤:error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
  • 解決方法:
    檢查是否有libaio庫# rpm -qa|grep libaio,如果沒有則安裝# yum install libaio。

    轉載于:https://www.cnblogs.com/junio/p/10608714.html

    總結

    以上是生活随笔為你收集整理的CentOS 7 MySql 解压版安装配置的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。