zoukankan      html  css  js  c++  java
  • 二进制安装mysql5.7

    下载地址:https://downloads.mysql.com/archives/community/

    [root@localhost soft]# ls
    mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz nginx-1.12.2 nginx-1.12.2.tar.gz
    [root@localhost soft]#
    

      

    1.详细描安装的过程

    1.1关闭防火墙

    systemctl stop firewalld.service #停止firewall
    systemctl disable firewalld.service #禁止firewall开机启动
    firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
    

      

    检查是否安装NySQL,如果安装 卸载之

    rpm -qa |grep mysql

    yum remove mysql*

    检查是否安装MariaDB,如果安装 卸载之(重要)

    rpm -qa |grep mariadb

    yum remove mariadb*

     新增用户/组 参数文件

    groupadd mysql

    useradd mysql -g mysql -M -s /sbin/nologin

    创建目录并授权

    mkdir -p /data/3306 

    mkdir log

    chown -R mysql.mysql /data

    配置文件和启动文件修改:

     mv ./my.cnf /etc/

     cp /application/mysql/support-files/mysql.server  /etc/init.d/mysqld

    vim /etc/init.d/mysqld

    修改:

    basedir=/application/mysql
    datadir=/data/3306/data

    初始化:

     ./bin/mysqld  --initialize --user=mysql --basedir=/application/mysql --datadir=/data/3306/data

    [root@localhost 3306]# ll
    总用量 4
    drwxr-x--- 5 mysql mysql 147 8月   5 23:30 data
    drwxr-xr-x 2 mysql mysql  34 8月   5 23:30 log
    -rw-r----- 1 mysql mysql 802 8月   5 23:30 mysql_error.log
    

      

    [root@localhost data]# ll
    总用量 143396
    -rw-r----- 1 mysql mysql       56 8月   5 23:30 auto.cnf
    -rw-r----- 1 mysql mysql      413 8月   5 23:30 ib_buffer_pool
    -rw-r----- 1 mysql mysql 12582912 8月   5 23:30 ibdata1
    -rw-r----- 1 mysql mysql 67108864 8月   5 23:30 ib_logfile0
    -rw-r----- 1 mysql mysql 67108864 8月   5 23:30 ib_logfile1
    drwxr-x--- 2 mysql mysql     4096 8月   5 23:30 mysql
    drwxr-x--- 2 mysql mysql     8192 8月   5 23:30 performance_schema
    drwxr-x--- 2 mysql mysql     8192 8月   5 23:30 sys
    

      

    [root@localhost 3306]# grep 'temporary password' ./mysql_error.log 
    2018-08-05T15:30:45.859098Z 1 [Note] A temporary password is generated for root@localhost: r6IiVQkl_mfm
    r6IiVQkl_mfm为mysql的root用户登录的随机密码

    启动mysql
    [root@localhost 3306]# service mysqld start
    Starting MySQL.2018-08-05T15:35:41.111817Z mysqld_safe The file /usr/local/mysql/bin/mysqld
    does not exist or is not executable. Please cd to the mysql installation
    directory and restart this script from there as follows:
    ./bin/mysqld_safe&
    See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
     ERROR! The server quit without updating PID file (/data/3306/data/localhost.localdomain.pid).
    [root@localhost 3306]# 
    

      

    会发现报错了。。。。。。。。不要慌

    错误:/usr/local/mysql/bin/mysqld does not exist 

    解决:

    [root@localhost 3306]# mkdir -p /usr/local/mysql/bin
    [root@localhost 3306]# ln -s /application/mysql/bin/mysqld  /usr/local/mysql/bin
    

      

    大功告成了:

    [root@localhost 3306]# service mysqld start                                     
    Starting MySQL.. SUCCESS! 
    

      

    把mysql命令加到环境变量中

    vim /etc/profile
    最底下修改:
    PATH="/application/mysql/bin/:$PATH"
    tail -1  /etc/profile
    source /etc/profile
    [root@localhost 3306]# ps -ef|grep mysqld
    root      3822     1  0 23:38 pts/2    00:00:00 /bin/sh /application/mysql/bin/mysqld_safe --datadir=/data/3306/data --pid-file=/data/3306/data/localhost.localdomain.pid
    mysql     4275  3822  0 23:38 pts/2    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/application/mysql --datadir=/data/3306/data --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/data/3306/mysql_error.log --open-files-limit=65535 --pid-file=/data/3306/data/localhost.localdomain.pid --socket=/data/3306/mysql.sock --port=3306
    root      4378  2807  0 23:42 pts/2    00:00:00 grep --color=auto mysqld

    登录mysql: 密码为上面随机密码

    mysql -uroot -pr6IiVQkl_mfm

    登录成功之后再修改密码:

    mysql> set PASSWORD=PASSWORD('123456');
    Query OK, 0 rows affected, 1 warning (0.00 sec)

    flush privileges;

      

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)

    mysql远程链接:

    mysql> use mysql;
    Database changed
    mysql> update user set host ='%'where user ='root' and host ='localhost';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select host,user from user;         
    +-----------+-----------+
    | host      | user      |
    +-----------+-----------+
    | %         | root      |
    | localhost | mysql.sys |
    +-----------+-----------+
    2 rows in set (0.00 sec)
    
    mysql> 

     

    [root@localhost 3306]# ll
    总用量 20
    drwxr-x--- 6 mysql mysql   229 8月   5 23:51 data
    drwxr-xr-x 2 mysql mysql    34 8月   5 23:30 log
    -rw-r----- 1 mysql mysql 12690 8月   5 23:51 mysql_error.log
    srwxrwxrwx 1 mysql mysql     0 8月   5 23:51 mysql.sock
    -rw------- 1 mysql mysql     5 8月   5 23:51 mysql.sock.lock
    [root@localhost data]# ll
    总用量 155692
    -rw-r----- 1 mysql mysql       56 8月   5 23:30 auto.cnf
    -rw-r----- 1 mysql mysql      384 8月   5 23:50 ib_buffer_pool
    -rw-r----- 1 mysql mysql 12582912 8月   5 23:51 ibdata1
    -rw-r----- 1 mysql mysql 67108864 8月   5 23:51 ib_logfile0
    -rw-r----- 1 mysql mysql 67108864 8月   5 23:30 ib_logfile1
    -rw-r----- 1 mysql mysql 12582912 8月   5 23:51 ibtmp1
    -rw-r----- 1 mysql mysql        5 8月   5 23:51 localhost.localdomain.pid
    drwxr-x--- 2 mysql mysql     4096 8月   5 23:30 mysql
    -rw-rw---- 1 root  root         5 8月   5 23:51 mysqld_safe.pid
    drwxr-x--- 2 mysql mysql     8192 8月   5 23:30 performance_schema
    drwxr-x--- 2 mysql mysql     8192 8月   5 23:30 sys
    drwxr-x--- 2 mysql mysql       52 8月   5 23:49 test

    完结。。。。。。。。。。。。。。。。。就这么简单




  • 相关阅读:
    前世今生:Hive、Shark、spark SQL
    spark streaming 6: BlockGenerator、RateLimiter
    spark streaming 5: InputDStream
    spark streaming 4: DStreamGraph JobScheduler
    常见css水平自适应布局
    js动态加载以及确定加载完成的代码
    如何判断css是否加载完成
    翻书特效
    jquery 事件冒泡的介绍以及如何阻止事件冒泡
    phonegap之android原生日历调用
  • 原文地址:https://www.cnblogs.com/sunlong88/p/9427839.html
Copyright © 2011-2022 走看看