zoukankan      html  css  js  c++  java
  • linux下mysql 5.7.22 安装

    二进制安装

    1.下载https://dev.mysql.com/downloads/mysql/5.6.html#downloads

    2.官方文档https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    [root@localhost local]# yum install libaio
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.aliyun.com
     * extras: mirrors.huaweicloud.com
     * updates: mirrors.aliyun.com
    Package libaio-0.3.109-13.el7.x86_64 already installed and latest version
    Nothing to do
    [root@localhost local]# pwd
    /usr/local
    [root@localhost local]# tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
    [root@localhost local]# ln -s mysql-5.7.22-linux-glibc2.12-x86_64 mysql
    [root@localhost local]groupadd mysql
    [root@localhost localuseradd -r -g mysql -s /bin/false mysql
    [root@localhost localchown -R mysql:mysql mysql
    [root@localhost local]# cd mysql
    [root@localhost mysql]# ll
    total 40
    drwxr-xr-x.  2 root  root   4096 May 15 03:59 bin
    -rw-r--r--.  1  7161 31415 17987 Mar  4 21:40 COPYING
    drwxr-x---.  5 mysql mysql  4096 May 15 04:39 data
    drwxr-xr-x.  2 root  root     55 May 15 03:59 docs
    drwxr-xr-x.  3 root  root   4096 May 15 03:58 include
    drwxr-xr-x.  5 root  root    229 May 15 03:59 lib
    drwxr-xr-x.  4 root  root     30 May 15 03:59 man
    -rw-r--r--.  1  7161 31415  2478 Mar  4 21:40 README
    drwxr-xr-x. 28 root  root   4096 May 15 03:59 share
    drwxr-xr-x.  2 root  root     90 May 15 03:59 support-files
     
    [root@localhost mysql]bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

      

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [root@localhost mysql]# bin/mysql_ssl_rsa_setup  --datadir=/usr/local/mysql/data
    [root@localhost mysql]# cd support-files/
    [root@localhost support-files]# vi  /etc/my.cnf
    [root@localhost mysql]# cat /etc/my.cnf
    [mysqld]
    basedir=/usr/local/mysql/
    datadir=/usr/local/mysql/data/<br>character_set_server = utf8
    [root@localhost support-files]# cd ..
    [root@localhost mysql]# cd bin/
    [root@localhost bin]# ./mysqld_safe --user=mysql &
    [1] 2942

      启动完毕

    登录,修改root密码  设置远程登录

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    [root@localhost mysql]# mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.22
     
    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> set password=password("root");
    Query OK, 0 rows affected, 1 warning (0.00 sec)
     
    mysql> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
     
    Database changed
    mysql> update  user  set host='%' where user='root';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
     
    mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY '......' WITH GRANT OPTION;
    Query OK, 0 rows affected, 1 warning (0.00 sec)
     
    mysql> FLUSH PRIVILEGES; 
    Query OK, 0 rows affected (0.00 sec)
     
    mysql> exit;

      设置开机自启

    1
    2
    3
    4
    [root@localhost support-files]# cp mysql.server /etc/init.d/mysql
    [root@localhost support-files]# chmod +x /etc/init.d/mysql
    [root@localhost support-files]# chkconfig --add mysql
    [root@localhost support-files]# chkconfig --list mysql 

      

    [root@localhost support-files]# service mysql stop

    [root@localhost support-files]# service mysql start

    配置环境变量:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    [root@localhost local]# mysql -uroot -p
    -bash: mysql: command not found
    [root@localhost local]# ln -s /usr/local/mysql/bin/mysql /usr/bin
    [root@localhost local]# mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.22 MySQL Community Server (GPL)
     
    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远程登录问题:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    mysql> use mysql;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
     
    Database changed
    mysql> update user set host = '%' where user = 'root';
    Query OK, 0 rows affected (0.11 sec)
    Rows matched: 1  Changed: 0  Warnings: 0
     
    mysql> select host,user from user;
    +-----------+---------------+
    | host      | user          |
    +-----------+---------------+
    | %         | myuser        |
    | %         | root          |
    | %         | sec_user      |
    | localhost | mysql.session |
    | localhost | mysql.sys     |
    | localhost | sec_user      |
    +-----------+---------------+
    6 rows in set (0.00 sec)<br><br>

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    C:UsersAdministrator>mysql -u sec_user -h 192.168.222.13 -p
    Enter password: ********
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 12
    Server version: 5.7.22 MySQL Community Server (GPL)
     
    Copyright (c) 2000, 2015, 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 |
    | securities_master  |
    +--------------------+
    2 rows in set (0.00 sec)
     
    mysql> use securities_master;
    Database changed
    mysql> show tables;
    +-----------------------------+
    | Tables_in_securities_master |
    +-----------------------------+
    | daily_price                 |
    | data_vendor                 |
    | exchange                    |
    | symbol                      |
    +-----------------------------+
    4 rows in set (0.00 sec)
     
    mysql>

      

    注意:1.mysql默认的字符集是Latin ,需要修改my.cnf   设置为utf-8,并且重启,验证

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    mysql> show variables like 'character_set_database';
    +------------------------+-------+
    | Variable_name          | Value |
    +------------------------+-------+
    | character_set_database | utf8  |
    +------------------------+-------+
    1 row in set (0.01 sec)
     
    mysql> show variables like 'character%';
    +--------------------------+----------------------------------------------------------------+
    | Variable_name            | Value                                                          |
    +--------------------------+----------------------------------------------------------------+
    | character_set_client     | utf8                                                           |
    | character_set_connection | utf8                                                           |
    | character_set_database   | utf8                                                           |
    | character_set_filesystem | binary                                                         |
    | character_set_results    | utf8                                                           |
    | character_set_server     | utf8                                                           |
    | character_set_system     | utf8                                                           |
    | character_sets_dir       | /usr/local/mysql-5.7.22-linux-glibc2.12-x86_64/share/charsets/ |
    +--------------------------+----------------------------------------------------------------+

    2.开机启动关闭防火墙 

        Centos7的防火墙用firewalld.service,而不是iptable……

        systemctl stop firewalld.service

        systemctl disable firewalld.service

     

    参考文档:

    https://blog.csdn.net/qq_37995908/article/details/79092363

    https://blog.csdn.net/ctypyb2002/article/details/79757070

    https://blog.csdn.net/mengfei86/article/details/51189624

     
  • 相关阅读:
    单例模式
    js事件
    oracle_to_excel
    jquery_2
    jquery_1
    4.linux 复制,删除,重命名
    一个tomcat下部署多个springboot项目
    3.centos7 安装oracle
    桥接模式
    组合模式
  • 原文地址:https://www.cnblogs.com/drizzle-xu/p/9728438.html
Copyright © 2011-2022 走看看