您好,登錄后才能下訂單哦!
下面一起來了解下MySQL數據庫的優勢及安裝方法,相信大家看完肯定會受益匪淺,文字在精不在多,希望MySQL數據庫的優勢及安裝方法這篇短內容是你想要的。
數據庫的基本概念
數據
在每個二維表中, 每一行稱為一條記錄,用來描述一個對象的信息;每一列稱為一個字段,用來描述對象的一個屬性
Memcached是一 個開源的、高性能的、具有分布式內存對象的緩存系統,以key-value方式存儲數據
[root@localhost ~]# yum install gcc gcc-c++ make ncurses ncurses-devel bison cmake -y //安裝環境包 已加載插件:fastestmirror, langpacks base | 3.6 kB 00:00:00 extras | 2.9 kB 00:00:00 ... 已安裝: bison.x86_64 0:3.0.4-2.el7 cmake.x86_64 0:2.8.12.2-2.el7 gcc.x86_64 0:4.8.5-39.el7 gcc-c++.x86_64 0:4.8.5-39.el7 ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 作為依賴被安裝: cpp.x86_64 0:4.8.5-39.el7 glibc-devel.x86_64 0:2.17-292.el7 glibc-headers.x86_64 0:2.17-292.el7 kernel-headers.x86_64 0:3.10.0-1062.4.3.el7 libmpc.x86_64 0:1.0.1-3.el7 libstdc++-devel.x86_64 0:4.8.5-39.el7 m4.x86_64 0:1.4.16-10.el7 更新完畢: make.x86_64 1:3.82-24.el7 ncurses.x86_64 0:5.9-14.20130511.el7_4 作為依賴被升級: glibc.x86_64 0:2.17-292.el7 glibc-common.x86_64 0:2.17-292.el7 libgcc.x86_64 0:4.8.5-39.el7 libgomp.x86_64 0:4.8.5-39.el7 libstdc++.x86_64 0:4.8.5-39.el7 ncurses-base.noarch 0:5.9-14.20130511.el7_4 ncurses-libs.x86_64 0:5.9-14.20130511.el7_4 完畢! [root@localhost ~]# useradd -s /sbin/nologin mysql //創建MySQL程序型用戶 [root@localhost ~]# mount.cifs //192.168.100.8/shares /mnt/ //將宿主機中MySQL壓縮包路徑掛載到Linux系統中 Password for root@//192.168.100.8/shares: [root@localhost ~]# cd /mnt/ //進入掛載點目錄 [root@localhost mnt]# tar zxvf mysql-boost-5.7.20.tar.gz -C /opt //解壓MySQL壓縮包到opt目錄 ...... mysql-5.7.20/boost/boost_1_59_0/boost/unordered/detail/extract_key.hpp mysql-5.7.20/boost/boost_1_59_0/boost/unordered/detail/buckets.hpp mysql-5.7.20/boost/boost_1_59_0/boost/unordered/detail/allocate.hpp mysql-5.7.20/boost/boost_1_59_0/boost/unordered/detail/util.hpp mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_map.hpp mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_set.hpp mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_set_fwd.hpp mysql-5.7.20/boost/boost_1_59_0/boost/unordered/unordered_map_fwd.hpp mysql-5.7.20/boost/boost_1_59_0/boost/timer.hpp [root@localhost mnt]# cd /opt/mysql-5.7.20/ [root@localhost mysql-5.7.20]# cmake \ //配置mysql > -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //指定安裝路徑 > -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ //指定mysql.sock.路徑 > -DSYSCONFDIR=/etc \ //指定配置文件存放位置 > -DSYSTEMD_PID_DIR=/usr/local/mysql \ //指定pid文件存放為位置 > -DDEFAULT_CHARSET=utf8 \ //字符集格式utf-8 > -DDEFAULT_COLLATION=utf8_general_ci \ > -DWITH_INNOBASE_STORAGE_ENGINE=1 \ //開啟存儲引擎 > -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ > -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ > -DMYSQL_DATADIR=/usr/local/mysql/data \ //指定數據存放位置 > -DWITH_BOOST=boost \ //關聯支持c++運行庫 > -DWITH_SYSTEMD=1 //開啟systemd .... -- CMAKE_C_LINK_FLAGS: -- CMAKE_CXX_LINK_FLAGS: -- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF -- Configuring done -- Generating done -- Build files have been written to: /opt/mysql-5.7.20 [root@localhost mysql-5.7.20]# make //make過程(時間比較長,耐心等待) .... [100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o Linking CXX executable mysql_embedded [100%] Built target mysql_embedded Scanning dependencies of target mysqltest_embedded [100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o Linking CXX executable mysqltest_embedded [100%] Built target mysqltest_embedded Scanning dependencies of target my_safe_process [100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o Linking CXX executable my_safe_process [100%] Built target my_safe_process [root@localhost mysql-5.7.20]# make install //安裝 ... -- Installing: /usr/local/mysql/./COPYING-test -- Installing: /usr/local/mysql/./README-test -- Up-to-date: /usr/local/mysql/mysql-test/mtr -- Up-to-date: /usr/local/mysql/mysql-test/mysql-test-run -- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process -- Up-to-date: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process -- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/Base.pm -- Installing: /usr/local/mysql/support-files/mysqld_multi.server -- Installing: /usr/local/mysql/support-files/mysql-log-rotate -- Installing: /usr/local/mysql/support-files/magic -- Installing: /usr/local/mysql/share/aclocal/mysql.m4 -- Installing: /usr/local/mysql/support-files/mysql.server [root@localhost mysql-5.7.20]# cd /usr/local/ //進入安裝目錄 [root@localhost local]# chown -R mysql.mysql mysql/ //mysql目錄更改用戶與組 [root@localhost local]# mv /etc/my.cnf /etc/my.cnf.bak //更改配置文件名稱 [root@localhost local]# vim /etc/my.cnf //重新編輯配置文件 [client] port = 3306 default-character-set=utf8 socket = /usr/local/mysql/mysql.sock [mysql] port = 3306 default-character-set=utf8 socket = /usr/local/mysql/mysql.sock [mysqld] user = mysql basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 character_set_server=utf8 pid-file = /usr/local/mysql/mysqld.pid socket = /usr/local/mysql/mysql.sock server-id = 1 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES :wq [root@localhost local]# vim /etc/profile ... PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH export PATH //重新聲明環境變量 :wq [root@localhost local]# source /etc/profile //重新執行 [root@localhost local]# cd /usr/local/mysql/bin //進入MySQL命令目錄 [root@localhost bin]# mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data //初始化數據庫 2019-12-02T11:51:28.112082Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-12-02T11:51:28.263398Z 0 [Warning] InnoDB: New log files created, LSN=45790 2019-12-02T11:51:28.287408Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2019-12-02T11:51:28.341284Z 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: 131f32df-14fa-11ea-87e6-000c297265cb. 2019-12-02T11:51:28.342106Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2019-12-02T11:51:28.342452Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. [root@localhost ~]# cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /lib/systemd/system/ //將MySQL啟動腳本夫復制到系統system目錄下 [root@localhost ~]# systemctl enable mysqld.service //設置MySQL為開機自啟動 Created symlink from /etc/systemd/system/multi-user.target.wants/mysqld.service to /usr/lib/systemd/system/mysqld.service. [root@localhost ~]# systemctl start mysqld.service //啟動MySQL [root@localhost ~]# mysqladmin -u root -p password //設置MySQL數據庫密碼 Enter password: //沒有原始密碼,直接回車 New password: //輸入新密碼 Confirm new password: //再次輸入密碼 Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety. //安全提示 [root@localhost ~]# mysql -u root -p //登錄MySQL Enter password: 輸入密碼 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.20 Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; //查看數據庫 +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+4 rows in set (0.00 sec)
看完MySQL數據庫的優勢及安裝方法這篇文章后,很多讀者朋友肯定會想要了解更多的相關內容,如需獲取更多的行業信息,可以關注我們的行業資訊欄目。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。