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

    安装系统所需要的依赖包

    [root@namenode ~]# yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cmake  bison

    创建mysql用户与用户组

    [root@namenode ~]# groupadd mysql

    [root@namenode ~]# useradd -r -g mysql mysql

    安装mysql

    [root@namenode ~]# tar zxvf mysql-5.5.25.tar.gz

    [root@namenode ~]# cd mysql-5.5.25

    [root@namenode mysql-5.5.25]# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql/ -DMYSQL_DATADIR=/opt/mysql/data -DMYSQL_UNIX_ADDR=/opt/mysql/data/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/opt/mysql/data/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0

    [root@namenode mysql-5.5.25]# make && make install

    赋予相关权限

    [root@namenode mysql-5.5.25]# chown -R mysql:mysql /opt/mysql

    [root@namenode mysql-5.5.25]# /opt/mysql/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql  --datadir=/opt/mysql/data

    mysql配置文件

    [root@namenode mysql-5.5.25]# cp /opt/mysql/support-files/my-default.cnf /etc/my.cnf    -----有的是

    这个文件路径--- cp /opt/mysql/support-files/my-large.cnf /etc/my.cnf     可是没有找打这个文件

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

    [root@namenode mysql-5.5.25]# chmod +x /etc/init.d/mysql

    增加自动启动

    [root@namenode mysql-5.5.25]# chkconfig mysql on

    启动mysql

    [root@namenode mysql-5.5.25]# /etc/init.d/mysql start

    Starting MySQL......                                      [ OK ]

    查看mysql 的3306端口,看到下面说明启动成功

    [root@namenode mysql-5.5.25]#ps aux | grep 3306

    mysql   17237 3.6 8.4 615660 86264 pts/2   Sl  22:10  0:01 /opt/mysql/bin/mysqld --basedir=/opt/mysql --datadir=/opt/mysql/data --plugin-dir=/opt/mysql/lib/plugin --user=mysql --log-error=/opt/mysql/data/namenode.err --pid-file=/opt/mysql/data/namenode.pid --socket=/opt/mysql/data/mysql.sock --port=3306

    root    17798 0.0 0.0 61228  784 pts/2   S+  22:10  0:00 grep 3306

    设置mysql初始密码,123456是密码,你可以设置自己需要的密码

     
    [root@namenode mysql-5.5.25]# /opt/mysql/bin/mysqladmin -u root password '123456'
    /usr/bin/mysqladmin -u root password 'Ovk!@#123'
     
    [root@namenode mysql-5.5.25]# /opt/mysql/bin/mysql -uroot -p123456

    Welcome to the MySQL monitor. Commands end with ; or g.

    Your MySQL connection id is 2

    Server version: 5.5.25-log Source distribution

    Copyright (c) 2000, 2011, 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远程权限
    mysql> grant all on *.* to root@'%' identified by '123456';
    grant all on *.* to root@'%' identified by 'Ovk!@#123';  
     
     LINUX:
    编辑/etc/my.cnf文件,在[mysqld]节下 添加 lower_case_table_names=1 参数,并设置相应的值 (备注:为0时大小写敏感,为1时大小写不敏感,默认为0)。”(引用网上文章中的句子)。
     
     开启Linux系统3306端口

    二、配置防火墙,开启3306端口

    vi /etc/sysconfig/iptables #编辑

    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口

    特别提示:如果这两条规则添加到防火墙配置的最后一行,导致防火墙启动失败,正确的应该是添加到默认的22端口这条规则的下面,添加好之后防火墙规则如下所示:

    #########################################################

    # Firewall configuration written by system-config-securitylevel

    # Manual customization of this file is not recommended.

    *filter

    :INPUT ACCEPT [0:0]

    :FORWARD ACCEPT [0:0]

    :OUTPUT ACCEPT [0:0]

    :RH-Firewall-1-INPUT - [0:0]

    -A INPUT -j RH-Firewall-1-INPUT

    -A FORWARD -j RH-Firewall-1-INPUT

    -A RH-Firewall-1-INPUT -i lo -j ACCEPT

    -A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT

    -A RH-Firewall-1-INPUT -p 50 -j ACCEPT

    -A RH-Firewall-1-INPUT -p 51 -j ACCEPT

    -A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT

    -A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT

    -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT

    -A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

    -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

    -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

    COMMIT

    #########################################################

     
    /etc/init.d/iptables restart #最后重启防火墙使配置生效
     
     

    Centos7开放端口

     
    Centos升级到7之后,发现无法使用iptables控制Linuxs的端口,google之后发现Centos 7使用firewalld代替了原来的iptables。下面记录如何使用firewalld开放Linux端口:

    开启端口
    +firewall-cmd --zone=public --add-port=80/tcp --permanent
    命令含义:
    --zone #作用域
    --add-port=80/tcp #添加端口,格式为:端口/通讯协议
    --permanent #永久生效,没有此参数重启后失效
    重启防火墙
    firewall-cmd --reload
    详细信息可以参考以下资料:
    http://stackoverflow.com/questions/24729024/centos-7-open-firewall-port
    https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html

     

  • 相关阅读:
    N个数求和
    求整数段和
    连续因子
    L1-005 考试座位号
    PTA Java tips(转载)
    个位数统计
    flink编译支持CDH6.2.0(hadoop3.0.0)
    hdfs/hbase 程序利用Kerberos认证超过ticket_lifetime期限后异常
    spring boot通过@Bean注解定义一个Controller
    【TypeScript】TypeScript 学习 2——接口
  • 原文地址:https://www.cnblogs.com/tiechui2015/p/10390773.html
Copyright © 2011-2022 走看看