centos7 php开发环境安装-mysql

Posted 微刻时光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 php开发环境安装-mysql相关的知识,希望对你有一定的参考价值。

mysql安装

1.安装cmake(作为mysql的安装工具)

      tar -zxvf cmake-3.8.0.tar.gz

     cd cmake-3.8.0

    ./bootstrap

    gmake

   gmake install

 2.安装boost_1_59_0

      tar -zxvf boost_1_59_0.tar.gz

     cd boost_1_59_0

    ./bootstrap.sh

    ./b2

    ./b2 install

3.创建用户、配置目录

         添加mysql用户和所属组

         /usr/sbin/groupadd mysql

        /usr/sbin/useradd  -g mysql mysql

     创建mysql安装目录和数据目录

        mkdir /usr/local/mysql

        mkdir /usr/local/mysql/data

     修改mysql目录所有者

        chown -R mysql:mysql /usr/local/mysql

4.安装mysql

       tar -zxvf mysql-5.7.14.tar.gz

       cd mysql-5.7.14

       以下复制到文本中

        cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data  -DDOWNLOAD_BOOST=1  -DWITH_BOOST=/usr/local/src/boost_1_59_0 -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock  -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1  -DWITHOUT_PARTITION_STORAGE_ENGINE=1  -DWITH_FAST_MUTEXES=1  -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1  -DWITH_READLINE=1  -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0

 

       make

      make install

      

5.mysql安装失败重新编译时,需要清除旧的对象文件和缓存信息

      make clean

     rm -f CMakeCache.txt

    rm -rf /etc/my.cnf

6.配置mysql并初始化数据库

       配置文件:

            cp /usr/local/mysql/support-files/my-default.cnf  /etc/my.cnf

       初始化数据库:

           ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

    启动mysql数据库

      /usr/local/mysql/bin/mysqld_safe -defaults-file=/etc/my.cnf -basedir=/usr/local/mysql  --datadir=/usr/local/mysql/data -user=mysql & ./--mysqld_safe --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql &

       查看是否启动

      ps -ef | grep mysqld

     建立软链接:

     ln -s /usr/local/mysql/bin/mysql    /usr/bin

7.修改初始化密码

        mysql  -u root  -p

       Set password = password(‘xxx‘);

       Alter user ‘root‘@‘localhost‘ password expire never;

       grant all privileges on *.* to root@‘%‘ identified by ‘xxx‘;

      grant all privileges on *.* to ‘root‘@‘%‘ identified by ‘xxx‘ with grant option;

      Flush privileges;

 

8.开机启动

  1. touch /usr/lib/systemd/system/mysql.service

         2.设置内容

        

[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf
LimitNOFILE = 5000
#Restart=on-failure
#RestartPreventExitStatus=1
#PrivateTmp=false

9.操作     

        systemctl start mysql

       systemctl stop mysql

      systemctl restart mysql

       systemctl disable mysql

       systemctl enable mysql

       systemctl status mysql

  

以上是关于centos7 php开发环境安装-mysql的主要内容,如果未能解决你的问题,请参考以下文章

开发环境搭建(lnmp)

centos7 安装mysql+php环境

centOS7 安装nginx+php+mysql

CentOS7 搭建nginx+php+mysql运行环境

CentOS 7 安装PHP7+Nginx+Mysql5.7开发环境

centos7 搭建lamp(Apache PHP Mysql环境)