centos 7 MysSQL 5.6.39 源码安装-程序员宅基地

MySQL 5.6.39 二进制安装

CentOS 7 将默认数据库MySQL替换成了Mariadb
这里会从系统的环境准备开始一步一步安装。

环境准备

系统版本 内核版本 IP地址
Centos 7.5 4.18.9-1.el7.elrepo.x86_64 10.0.0.3

备注 该系统采用MINI最小化安装,安装之后对系统进行了最基础的优化操作,操作过程点击这里

删除系统自带的依赖包

[root@node soft]# rpm -qa | egrep 'mysql|mariadb'
mariadb-libs-5.5.56-2.el7.x86_64
[root@node soft]# rpm -qa | egrep 'mysql|mariadb' | xargs rpm -e --nodeps
[root@node soft]# rpm -qa | egrep 'mysql|mariadb'
[root@node soft]# 

创建MySQL运行用户

[root@node soft]# useradd -s /sbin/nologin -M mysql
[root@node soft]# grep mysql /etc/passwd
mysql:x:1000:1000::/home/mysql:/sbin/nologin

下载 MySQL

可以在mirrors.163.com的163源下载,点击我下载

如果上面的下载地址失效了,则可以使用百度网盘:链接:https://pan.baidu.com/s/1Ubr_aZbKgiYKuL8cegkP0w
提取码:dkr7

[root@node soft]# wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39.tar.gz
[root@node soft]# ls
mysql-5.6.39.tar.gz
# 解压
[root@node soft]# tar xf mysql-5.6.39.tar.gz 
[root@node soft]# ls
mysql-5.6.39  mysql-5.6.39.tar.gz

编译安装

首先准备编译环境

使用yum下载编译工具和其他依赖包

[root@node soft]# yum install cmake bison git ncurses-devel gcc gcc-c++ -y

使用cmake编译工具对mysql进行编译

[root@node soft]# pwd
/opt/soft
[root@node soft]# ls
mysql-5.6.39  mysql-5.6.39.tar.gz
[root@node soft]# cd mysql-5.6.39
[root@node mysql-5.6.39]# ls
BUILD   CMakeLists.txt  configure.cmake  Docs                 include   libmysql     man         mysys_ssl  README   sql         storage        tests     vio
client  cmd-line-utils  COPYING          Doxyfile-perfschema  INSTALL   libmysqld    mysql-test  packaging  regex    sql-bench   strings        unittest  win
cmake   config.h.cmake  dbug             extra                libevent  libservices  mysys       plugin     scripts  sql-common  support-files  VERSION   zlib
[root@node mysql-5.6.39]# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql-5.6.39 \
> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
> -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
> -DMYSQL_DATADIR=/opt/mysql-5.6.39/data \
> -DMYSQL_TCP_PORT=3306 \
> -DENABLE_DOWNLOADS=1
............................................................
.....................过程太多就不复制了.....................
............................................................
-- GTEST_LIBRARIES:gmock;gtest
-- Library mysqlserver depends on OSLIBS -lpthread;m;crypt;dl
-- Skipping deb packaging on unsupported platform .
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: HAVE_CONFIG_H
-- CMAKE_C_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- 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/soft/mysql-5.6.3


# 然后是构建安装
[root@node mysql-5.6.39]# make && make install
# make的时候回显示百分比,当结尾没有报错的时候,就说明安装完成了
............................................................
.....................过程太多就不复制了.....................
............................................................
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/innotest2b
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/run-all-tests
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/server-cfg
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-ATIS
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-alter-table
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-big-tables
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-connect
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-create
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-insert
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-select
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-transactions
-- Up-to-date: /opt/mysql-5.6.39/sql-bench/test-wisconsin
-- Installing: /opt/mysql-5.6.39/sql-bench/cmake_install.cmake
-- Installing: /opt/mysql-5.6.39/sql-bench/CTestTestfile.cmake
[root@node mysql-5.6.39]# ls /opt/
mysql-5.6.39  soft
# 这里可以看到已经安装完成了

配置环境变量

[root@node ~]# cd /opt/
[root@node opt]# ls
mysql-5.6.39  soft
[root@node opt]# chown -R mysql.mysql mysql-5.6.39/
[root@node opt]# echo 'export PATH=$PATH:/opt/mysql-5.6.39/bin' >> /etc/profile
[root@node opt]# tail -1 /etc/profile
export PATH=$PATH:/opt/mysql/bin
[root@node opt]# source /etc/profile
[root@node opt]# mysql -V
mysql  Ver 14.14 Distrib 5.6.39, for Linux (x86_64) using  EditLine wrapper

配置MySQL启动脚本并设置开机自启

二进制解压后的目录中,包括了MySQL的启动关闭脚本,可以使用,也可以自己写systemctl管理脚本

[root@node opt]# cd soft/mysql-5.6.39/
[root@node mysql-5.6.39]# pwd
/opt/soft/mysql-5.6.39
[root@node mysql-5.6.39]# ls
BUILD           cmake_install.cmake  COPYING                  Docs                 INSTALL               libservices      mysys           README            sql-bench      tests        win
client          CMakeLists.txt       CPackConfig.cmake        Doxyfile-perfschema  install_manifest.txt  make_dist.cmake  mysys_ssl       regex             sql-common     unittest     zlib
cmake           cmd-line-utils       CPackSourceConfig.cmake  extra                libevent              Makefile         packaging       scripts           storage        VERSION
CMakeCache.txt  config.h.cmake       CTestTestfile.cmake      include              libmysql              man              plugin          source_downloads  strings        VERSION.dep
CMakeFiles      configure.cmake      dbug                     info_macros.cmake    libmysqld             mysql-test       probes_mysql.o  sql               support-files  vio
[root@node mysql-5.6.39]# cp support-files/mysql.server
mysql.server          mysql.server.sh       mysql.server-sys5.sh  
[root@node mysql-5.6.39]# cp support-files/mysql.server /etc/init.d/mysqld
[root@node mysql-5.6.39]# chmod +x /etc/init.d/mysqld
[root@node mysql-5.6.39]# chkconfig --add mysqld
[root@node mysql-5.6.39]# chkconfig mysqld on
[root@node mysql-5.6.39]# chkconfig  | grep mysql

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

配置文件

[root@node mysql-5.6.39]# pwd
/opt/mysql-5.6.39
# 配置文件
[root@node mysql-5.6.39]# cat my.cnf 
[client]
port = 3306
socket = /tmp/mysql.sock

[mysql]
no-auto-rehash
   
[mysqld]
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /opt/mysql-5.6.39/
datadir = /opt/mysql-5.6.39/data
character_set_server=utf8
open_files_limit = 1024
back_log = 600
max_connections = 800
max_connect_errors = 3000
#table_cache = 614
external-locking = FALSE
max_allowed_packet = 8M
sort_buffer_size = 1M
join_buffer_size = 1M
thread_cache_size = 100
thread_concurrency = 2
query_cache_size = 2M
query_cache_limit = 1M
query_cache_min_res_unit = 2k
thread_stack = 192k
tmp_table_size = 2M
max_heap_table_size = 2M
long_query_time = 1
pid-file = /opt/mysql-5.6.39/mysql.pid
relay-log = /opt/mysql-5.6.39/log/relay-bin
relay-log-info-file = /opt/mysql-5.6.39/log/relay-log.info
binlog_cache_size = 1M
max_binlog_cache_size = 1M
max_binlog_size = 2M
key_buffer_size = 16M
read_buffer_size = 1M
read_rnd_buffer_size = 1M
bulk_insert_buffer_size = 1M
lower_case_table_names = 1
skip-name-resolve
slave-skip-errors = 1032,1062
replicate-ignore-db=mysql
server-id = 1
innodb_additional_mem_pool_size = 4M
innodb_buffer_pool_size = 32M
#innodb_data_file_path = ibdata1: 128M: autoextend
innodb_file_per_table = 0
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 4M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
   
   
[mysqldump]
quick
max_allowed_packet = 2M
   
[mysqld_safe]
log-error=/opt/mysql-5.6.39/error.log
pid-file=/opt/mysql-5.6.39/data/mysql.pid
[root@node mysql-5.6.39]#  touch /opt/mysql-5.6.39/error.log
[root@node mysql-5.6.39]#  chown -R mysql.mysql /opt/mysql-5.6.39/

启动 测试

[root@node mysql-5.6.39]# /etc/init.d/mysqld  start
Starting MySQL. SUCCESS! 
[root@node mysql-5.6.39]# ps aux|grep mysql
root      19073  0.6  0.1 113320  3120 pts/0    S    10:03   0:00 /bin/sh /opt/mysql-5.6.39//bin/mysqld_safe --datadir=/opt/mysql-5.6.39/data --pid-file=/opt/mysql-5.6.39/mysql.pid
mysql     19781  4.7 27.7 1505220 558988 pts/0  Sl   10:03   0:00 /opt/mysql-5.6.39/bin/mysqld --basedir=/opt/mysql-5.6.39/ --datadir=/opt/mysql-5.6.39/data --plugin-dir=/opt/mysql-5.6.39//lib/plugin --user=mysql --log-error=/opt/mysql-5.6.39/error.log --open-files-limit=1024 --pid-file=/opt/mysql-5.6.39/mysql.pid --socket=/tmp/mysql.sock --port=3306
root      19804  0.0  0.1 112716  2256 pts/0    S+   10:03   0:00 grep --color=auto mysql
[root@node mysql-5.6.39]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.39 Source distribution

Copyright (c) 2000, 2018, 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> 
mysql> 
mysql> 
mysql> \q
Bye

查看日志

[root@node mysql-5.6.39]# cat error.log
2018-09-30 10:03:20 19781 [Note] Plugin 'FEDERATED' is disabled.
2018-09-30 10:03:20 7fc9e78c9740 InnoDB: Warning: Using innodb_additional_mem_pool_size is DEPRECATED. This option may be removed in future releases, together with the option innodb_use_sys_malloc and with the InnoDB's internal memory allocator.
2018-09-30 10:03:20 19781 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-09-30 10:03:20 19781 [Note] InnoDB: The InnoDB memory heap is disabled
2018-09-30 10:03:20 19781 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-09-30 10:03:20 19781 [Note] InnoDB: Memory barrier is not used
2018-09-30 10:03:20 19781 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-09-30 10:03:20 19781 [Note] InnoDB: Using CPU crc32 instructions
2018-09-30 10:03:20 19781 [Note] InnoDB: Initializing buffer pool, size = 32.0M
2018-09-30 10:03:20 19781 [Note] InnoDB: Completed initialization of buffer pool
2018-09-30 10:03:20 19781 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-09-30 10:03:20 19781 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-09-30 10:03:20 19781 [Note] InnoDB: Database physically writes the file full: wait...
2018-09-30 10:03:21 19781 [Note] InnoDB: Setting log file ./ib_logfile101 size to 4 MB
2018-09-30 10:03:21 19781 [Note] InnoDB: Setting log file ./ib_logfile1 size to 4 MB
2018-09-30 10:03:21 19781 [Note] InnoDB: Setting log file ./ib_logfile2 size to 4 MB
2018-09-30 10:03:21 19781 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-09-30 10:03:21 19781 [Warning] InnoDB: New log files created, LSN=45781
2018-09-30 10:03:21 19781 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-09-30 10:03:21 19781 [Note] InnoDB: Doublewrite buffer created
2018-09-30 10:03:21 19781 [Note] InnoDB: 128 rollback segment(s) are active.
2018-09-30 10:03:21 19781 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-09-30 10:03:21 19781 [Note] InnoDB: Foreign key constraint system tables created
2018-09-30 10:03:21 19781 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-09-30 10:03:21 19781 [Note] InnoDB: Tablespace and datafile system tables created.
2018-09-30 10:03:21 19781 [Note] InnoDB: Waiting for purge to start
2018-09-30 10:03:21 19781 [Note] InnoDB: 5.6.39 started; log sequence number 0
2018-09-30 10:03:21 19781 [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: 017c96dd-c455-11e8-9dc5-000c2916c9b7.
2018-09-30 10:03:21 19781 [Note] Server hostname (bind-address): '*'; port: 3306
2018-09-30 10:03:21 19781 [Note] IPv6 is available.
2018-09-30 10:03:21 19781 [Note]   - '::' resolves to '::';
2018-09-30 10:03:21 19781 [Note] Server socket created on IP: '::'.
2018-09-30 10:03:21 19781 [Warning] 'user' entry 'root@node' ignored in --skip-name-resolve mode.
2018-09-30 10:03:21 19781 [Warning] 'user' entry '@node' ignored in --skip-name-resolve mode.
2018-09-30 10:03:21 19781 [Warning] 'proxies_priv' entry '@ root@node' ignored in --skip-name-resolve mode.
2018-09-30 10:03:21 19781 [Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
2018-09-30 10:03:21 19781 [Warning] Info table is not ready to be used. Table 'mysql.slave_master_info' cannot be opened.
2018-09-30 10:03:21 19781 [Warning] InnoDB: Cannot open table mysql/slave_worker_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
2018-09-30 10:03:21 19781 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
2018-09-30 10:03:21 19781 [Warning] Info table is not ready to be used. Table 'mysql.slave_relay_log_info' cannot be opened.
2018-09-30 10:03:21 19781 [Note] Event Scheduler: Loaded 0 events
2018-09-30 10:03:21 19781 [Note] /opt/mysql-5.6.39/bin/mysqld: ready for connections.
Version: '5.6.39'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution

至此 使用二进制包安装mysql完成

转载于:https://www.cnblogs.com/winstom/p/9728257.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_30776545/article/details/95678122

智能推荐

Java substring用法_java substring的用法-程序员宅基地

文章浏览阅读467次。public String substring(int beginIndex, int endIndex)返回一个新字符串,它是此字符串的一个子字符串。该子字符串从指定的 beginIndex 处开始,一直到索引 endIndex - 1 处的字符。因此,该子字符串的长度为 endIndex-beginIndex。示例: "ham_java substring的用法

fopen,fopen_s,_wfopen_s与_fsopen, _wfsopen的区分_fopen_s和fopen的区别-程序员宅基地

文章浏览阅读1.5w次,点赞2次,收藏13次。C++做项目的过程中,需要实现文件打开保存的一个功能,当我对文件tmp.dat进行写操作以后,想要第二次对此文件进行写操作,此时用fopen_s,_wfopen_s均出现返回int error = 13也就是EACCES (Permission denied)的错误。而由于项目是Unicode编码,没办法用fopen进行文件操作(其实只要在预编译中加入_CRT_SECURE_NO_WARN_fopen_s和fopen的区别

合工大计算机组成原理ppt,合工大 计算机组成原理 计算机组成原理提纲.pdf-程序员宅基地

文章浏览阅读251次。合工大 计算机组成原理 计算机组成原理提纲计算机组成原理计算机组成原理合肥工业大学计算机与信息学院陈陈 田田2013.12.12提 纲11 考试形式和试卷结构考试形式和试卷结构2 考查目标3 参考书目44 考点及重点难点分析考点及重点难点分析计算机与信息学院 ..._计算机组成原理合工大

PostgreSQL--读懂执行计划(一)_postgresql 执行计划-程序员宅基地

文章浏览阅读7.9k次,点赞5次,收藏42次。这里写自定义目录标题前言执行计划常用命令参数解读常用组合执行计划解读关键字常见扫描方式Seq ScanIndex Only ScanIndex ScanBitmap Index Scan+Bitmap Heap ScanHash JoinNested LoopMerge Join小结前言PostgreSQL为每个收到查询产生一个查询计划。 选择正确的计划来匹配查询结构和数据的属性对于好的性能来说绝对是最关键的,因此系统包含了一个复杂的规划器来尝试选择好的计划。 你可以使用EXPLAIN命令察看规划器为任_postgresql 执行计划

释放AI创作潜能:从大模型训练到高产力应用-程序员宅基地

文章浏览阅读1.4w次,点赞83次,收藏82次。随着科技的不断进步,人工智能已经成为了各行各业的必备技能。特别是在内容创作领域,人工智能生成内容(AIGC)正逐渐成为趋势。AI可以创造出优秀的、原创的文章和故事,这为创作者们提供了一种新的创作方式。同时,AIGC技术也可以节省人力成本,提高内容生产效率。但是,如何在使用技术的前提下保持内容的原创性和质量,这是我们需要思考的问题。

mysql root 访问被拒绝_mysql-“连接失败:用户'root'@'localhost'(使用密码:是)的访问被拒绝”...-程序员宅基地

文章浏览阅读3.7k次。mysql-“连接失败:用户'root'@'localhost'(使用密码:是)的访问被拒绝”这个问题在这里已有答案:MySQL错误1045(28000):用户'bill'@'localhost'的访问被拒绝(使用密码:是) 35个答案我写了一些PHP网页使用的函数,以便与mysql数据库进行交互。 当我在服务器上测试它们时,..._mysql -uroot -p 数据库访问拒绝oot @localhost

随便推点

Windows系统后台运行mysql程序_windows怎么让mysql一直运行-程序员宅基地

文章浏览阅读1.9w次。使用Windows中的任务计划程序来让net start MySQL命令在后台一直执行。_windows怎么让mysql一直运行

Version 1.8.0 251 of the JVM is not sitable for this product Version: 11 or greater is required._version 1.8.0 251 of the jvm is not suitable for t-程序员宅基地

文章浏览阅读1.2k次。eclipse报Version 1.8.0 251 of the JVM is not sitable for this product Version: 11 or greater is required.意思是JVM的1.8.0 251版本不适用于此产品版本:需要11或更高版本。解决办法:到https://www.oracle.com/java/technologies/javase-jdk16-downloads.html下载比11更高的版本,我这里下载16版本的解压后设置环境_version 1.8.0 251 of the jvm is not suitable for this product. version: 11 o

Tensorflow-gpu 1.13.1+Python 3.7.2+CUDA 10.0 +cuDNN7.5_tensorflow-gpu==1.13.1需要那个版本的python-程序员宅基地

文章浏览阅读8.3k次,点赞3次,收藏20次。最近在工作站上安装Tensorflow-gpu失败了很多次,由于坚信Tensorflow 1.13.1对Python3.7和新的CUDA的支持,一直没有放弃,现在终于配置成功了,把过程简单记录下来,希望能对大家有帮助。【电脑基础环境】硬件:工作站,显卡Nvidia quadro M5000软件:windows 7【软件安装过程】Anaconda3下载地址:https://www.a..._tensorflow-gpu==1.13.1需要那个版本的python

静态编译的方式合并第三方dll,并生成自己的dll,以及出现‘__acrt_first_block == header’异常解决方式_vs 将opencv的dll打包到自己的dll-程序员宅基地

文章浏览阅读4.7k次,点赞2次,收藏8次。有时候调用了第三方的dll,但是由于种种原因不能显示出来,需要将第三方dll封装到自己的dll里,在使用时,让别人只你的dll,而不用调用你使用的第三方dll。怎么实现?用静态编译的方式!最近由于项目需要,用VS2015+opencv2.4.13编程实现了静态编译生成自己的dll,这个dll相当于将opencv的部分功能封装到自己的dll中了(不要跟我说opencv开源,不需要封装到自己的d..._vs 将opencv的dll打包到自己的dll

unity Android安卓平台读取Application.persistentDataPath路径_unity怎么 读取 application.persistentdatapath 下的文件-程序员宅基地

文章浏览阅读3.1k次。这次这么测试是对的,下次再有问题再看看写入的时候这样写的: fileLocal = Application.persistentDataPath + "/" + path; finalPath =#if UNITY_ANDROID && !UNITY_EDITOR fileLocal;#else "file://" + fileLocal;#endif读取的时候这样写的: path =#._unity怎么 读取 application.persistentdatapath 下的文件

C语言 数据结构 栈的顺序表示和实现-程序员宅基地

文章浏览阅读2.8k次,点赞7次,收藏47次。栈的顺序表示和实现文章目录1 顺序栈结构2 基本操作函数3 整体代码test3.cStack.h4 运行结果5 附加题栈的存储结构可以是顺序表或链表,该篇为顺序表存储栈是后进先出的数据结构1 顺序栈结构栈结构体top永远指向下一个typedef struct Stack{ DataType data[maxn]; // 作为栈元素的存储方式,数据类型为DataType int top; // top即栈顶指_栈的顺序表示和实现