新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
下面一起来了解下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数据库的优势及安装方法这篇文章后,很多读者朋友肯定会想要了解更多的相关内容,如需获取更多的行业信息,可以关注我们的行业资讯栏目。