文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

linux系统下mysql的安装步骤

2024-04-02 19:55

关注

这篇文章主要讲解了“linux系统下mysql的安装步骤”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“linux系统下mysql的安装步骤”吧!


1:首先下载mysql 二进制安装文件
mysql-5.6.17.tar.gz
存放目录/u01/soft/mysql-5.6.17.tar.gz
tar -xf mysql-5.6.17.tar.gz
cd mysql-5.6.17
进行cmake,但是提示没有安装cmake

2:下载cmake
cmake-2.8.10.2.tar.gz
tar -xf cmake-2.8.10.2.tar.gz
./configure
make && make install

3:进行cmake
    先创建mysql 安装目录以及数据文件存放目录
        mkdir -p /mysql
        mkdir -p /mysql/data
    同时需要创建mysql 账号
        useradd mysql
        passwd mysql
    再进行目录授权:
        chown -R mysql:mysql /mysql
   cd mysql-5.6.17
 cmake \
        -DCMAKE_INSTALL_PREFIX=/mysql/ \               //mysql软件安装的根目录
        -DMYSQL_DATADIR=/mysql/data \                   //mysql 数据文件存放目录
        -DSYSCONFDIR=/etc \                                    //mysql 配置文件(my.cnf)目录
        -DWITH_MYISAM_STORAGE_ENGINE=1 \         //存储引擎选项
        -DWITH_INNOBASE_STORAGE_ENGINE=1 \    //以启用InnoDB、引擎支持:
        -DWITH_MEMORY_STORAGE_ENGINE=1 \
        -DWITH_READLINE=1 \                                 
        -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \   
        -DMYSQL_TCP_PORT=3306 \
        -DENABLED_LOCAL_INFILE=1 \                          //启用加载本地数据
        -DWITH_PARTITION_STORAGE_ENGINE=1 \        
        -DEXTRA_CHARSETS=all \
        -DDEFAULT_CHARSET=utf8 \                           //默认字符集
        -DDEFAULT_COLLATION=utf8_general_ci          //字符集校对
    进行编译,编译时报错如下:
            heck size of wctype_t - done
            -- Check size of wint_t
            -- Check size of wint_t - done
            -- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH) 
                CMake Error at cmake/readline.cmake:85 (MESSAGE):
                  Curses library not found.  Please install appropriate package,               remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
            Call Stack (most recent call first):
              cmake/readline.cmake:128 (FIND_CURSES)
              cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
              CMakeLists.txt:411 (MYSQL_CHECK_EDITLINE)
    这个报错是提示缺少ncurses-devel依赖包
    进行下载:ncurses-devel-5.7-3.20090208.el6.x86_64.rpm
        rpm -ivh ncurses-devel-5.7-3.20090208.el6.x86_64.rpm 
        warning: ncurses-devel-5.7-3.20090208.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
        Preparing...                ########################################### [100%]
       1:ncurses-devel          ########################################### [100%]
    同时rm -rf CMakeCache.txt 然后进行重新cmake
        完成之后,进行make && make install 进行mysql 安装
        - Installing: /mysql/man/man1/msql2mysql.1
        -- Installing: /mysql/man/man8/mysqld.8
        -- Installing: /mysql/support-files/solaris/postinstall-solaris
        算安装完成了,接下来就需要进行配置
4: 进入到mysql的安装目录,/mysql下:进行mysql 数据库初始化
        scripts/mysql_install_db --basedir=mysql --datadir=/mysql/data --user=mysql  //初始化mysql数据库
      但是报错
        [root@db_test scripts]# ./mysql_install_db  --basedir=mysql --datadir=/mysql/data --user=mysql
            FATAL ERROR: Could not find ./bin/my_print_defaults
               cd  /u01/soft/mysql-5.6.17/support-files
         
            cp  my-default.cnf /usr/local/mysql/my.cnf //copy配置文件

            [root@db_test support-files]# chown -R mysql:mysql /mysql
        vi /my.cnf 添加以下内容
    [mysqld]
    basedir = /mysql          
    datadir = /mysql/data  
    log-error = /mysql/mysql_error.log          
    pid-file = /mysql/mysql.pid          
    user = mysql
    tmpdir = /tmp 

    初始化mysql数据库
[root@db_test scripts]# ./mysql_install_db  --basedir=/mysql --datadir=/mysql/data --user=mysql
Installing MySQL system tables...2017-05-11 15:01:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-05-11 15:01:56 8161 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-05-11 15:01:56 8161 [Note] InnoDB: The InnoDB memory heap is disabled
2017-05-11 15:01:56 8161 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-05-11 15:01:56 8161 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-05-11 15:01:56 8161 [Note] InnoDB: Using CPU crc32 instructions
2017-05-11 15:01:56 8161 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-05-11 15:01:56 8161 [Note] InnoDB: Completed initialization of buffer pool
2017-05-11 15:01:56 8161 [Note] InnoDB: Highest supported file format is Barracuda.
2017-05-11 15:01:56 8161 [Note] InnoDB: Log scan progressed past the checkpoint lsn 1600617
2017-05-11 15:01:56 8161 [Note] InnoDB: Database was not shutdown normally!
2017-05-11 15:01:56 8161 [Note] InnoDB: Starting crash recovery.
2017-05-11 15:01:56 8161 [Note] InnoDB: Reading tablespace information from the .ibd files...
2017-05-11 15:01:56 8161 [Note] InnoDB: Restoring possible half-written data pages 
2017-05-11 15:01:56 8161 [Note] InnoDB: from the doublewrite buffer...

    或使用下列命令把mysql添加为系统服务
    cd/mysql/support-files/   
    cp ./mysql.server /etc/init.d/mysqld  
    /etc/init.d/mysqld start

    在配置环境变量
export PATH=$PATH:/mysql/bin

    [mysql@db_test ~]$ mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.17 Source distribution Copyright (c) 2000, 2014, 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 |
| test               |
+--------------------+
2 rows in set (0.00 sec) mysql> 

感谢各位的阅读,以上就是“linux系统下mysql的安装步骤”的内容了,经过本文的学习后,相信大家对linux系统下mysql的安装步骤这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯