zoukankan      html  css  js  c++  java
  • centos 7 安装mySql

    1,准备mySql源码安装

      # wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.19.tar.gz

    2:对于centos 7 安装mySql依赖项

          # yum install gcc-c++ make cmake bison bison-devel ncurses-devel libaio-devel perl

          # yum install perl-Data-Dumper

    3:安装cmake,下载cmake-2.8.10.2.tar.gz,自行下载

          # tar -zxv -f cmake-2.8.10.2.tar.gz

          # cd cmake-2.8.10.2

          # ./configure

          # make

          # make install

           接下来配置cmake环境变量

          # vi /etc/profile 》》在该文件中末尾追加下面两行

            PATH=/usr/local/cmake-2.8.10.2/bin:$PATH
            export PATH

          # source /etc/profile  》》执行后修改生效

          # echo $PATH    》》查看PATH值

    4:安装mySql

          创建安装路径和数据库保存路径

          安装路径: mkdir -p /usr/lcoal/mysql

          数据库路径:mkdir -p /usr/local/mysql/data

          创建mysql用户和组

                         groupadd mysql

                         useradd -r -g mysql mysql

          编译安装mysql

            # tar -zxv -f mysql-5.6.19.tar.gz

            # cd mysql-5.6.19

            #

         cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
         -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
         -DDEFAULT_CHARSET=utf8
         -DDEFAULT_COLLATION=utf8_general_ci
         -DWITH_MYISAM_STORAGE_ENGINE=1
         -DWITH_INNOBASE_STORAGE_ENGINE=1
         -DWITH_MEMORY_STORAGE_ENGINE=1
         -DWITH_READLINE=1
         -DENABLED_LOCAL_INFILE=1
         -DMYSQL_DATADIR=/mnt/db/mysql/data
         -DMYSQL_USER=root
         -DMYSQL_TCP_PORT=5001      

            # make 

            # make install

            检查是否安装成功

            到安装目录下 ls

            bin COPYING data docs include INSTALL-BINARY lib man mysql-test README scripts share sql-bench support-files
    有bin等以上文件的话,恭喜你已经成功安装了mysql。

            将mysql的启动服务添加到系统服务中

            # cp support-files/my-medium.cnf /etc/my.cnf

              cp:是否覆盖"/etc/my.cnf"? y

           创建系统数据库的表

           # cd /usr/local/mysql

           # scripts/mysql_install_db --user=mysql

            设置环境变量

            # vi /root/.bash_profile

            在修改PATH=$PATH:$HOME/bin为:
    PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib

            # source /root/.bash_profile //使刚才的修改生效

    手动启动mysql

    [root@localhost ~]# cd /usr/local/mysql  [root@localhost mysql]# ./bin/mysqld_safe --user=mysql & //启动MySQL,但不能停止 mysqladmin -u root -p shutdown //此时root还没密码,所以为空值,提示输入密码时,直接回车即可。

    将mysql的启动服务添加到系统服务中

    [root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysql

    启动mysql

    [root@localhost mysql]# service mysql start  Starting MySQL... ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).

    启动失败:  我这里是权限问题,先改变权限 [root@localhost mysql]# chown -R mysql:mysql /usr/local/mysql

    接着启动服务器 [root@localhost mysql]# /etc/init.d/mysql start

    修改MySQL的root用户的密码以及打开远程连接

    [root@localhost mysql]# mysql -u root mysql

    mysql> use mysql;  mysql> desc user;  mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //为root添加远程连接的能力 mysql> update user set Password = password('123456') where User='root'; //设置root用户密码 mysql> select Host,User,Password from user where User='root';  mysql> flush privileges;  mysql> exit

    重新登录

    [root@localhost mysql]# mysql -u root -p  Enter password:123456

    若还不能进行远程连接,关闭防火墙 [root@localhost]# /etc/rc.d/init.d/iptables stop

  • 相关阅读:
    WebService相关
    远程连接db2数据库
    修改VNC分辨率大小
    java面向对象的核心思想
    小故障排查
    使用IntelliJ IDEA开发java web
    WebService概述
    Qt开发之信号槽机制
    用SoapUI 测试Web Service
    剑指offer:滑动窗口的最大值
  • 原文地址:https://www.cnblogs.com/Yongzhouunknown/p/4805038.html
Copyright © 2011-2022 走看看