zoukankan      html  css  js  c++  java
  • Linux下安装MySQL

    1.下载

    http://dev.mysql.com/downloads/mysql/

    或者使用wget下载:

    wget http://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.22-1.el6.i686.rpm-bundle.tar

    2.安装

    2.1.检测是否已经安装了mysql

    rpm -qa | grep mysql

    如果已经安装了,将其卸载,如:

    rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64

    2.2.安装mysql

    1、 mkdir /usr/local/src/mysql
    2、 cd /usr/local/src/mysql
    3、 tar -xvf MySQL-5.6.22-1.el6.i686.rpm-bundle.tar
    4、 安装server
    rpm -ivh MySQL-server-5.6.22-1.el6.i686.rpm
    出错:安装依赖:yum -y install libaio.so.1 libgcc_s.so.1 libstdc++.so.6
    需要升级libstdc++-4.4.7-4.el6.x86_64
    yum update libstdc++-4.4.7-4.el6.x86_64
    5、 安装client
    安装依赖:yum -y install libncurses.so.5 libtinfo.so.5
    6、 查询mysq服务运行状态
    service mysql status
    7、 启动mysql服务
    service mysql start
    8、 使用root账号登录mysql
    在安装mysql server时有句提示:

    注意:这个密码是不安全的,所有需要修改初始密码。
    1)进入该文件查看密码

    ​ vi /root/.mysql_secret

    2)使用这个密码登录mysql

    ​ mysql –uroot –p密码

    3)修改密码

    ​ SET PASSWORD = PASSWORD('123');

    2.3.系统启动时自动启动mysql服务

    加入到系统服务:
    chkconfig --add mysql
    自动启动:
    chkconfig mysql on
    查询列表:
    chkconfig

    说明:都没关闭(off)时是没有自动启动。

    2.4.开启远程访问

    登录:
    mysql -uroot –p123456

    设置远程访问(使用root密码):
    grant all privileges on . to 'root' @'%' identified by '123456';
    flush privileges;

    防火墙打开3306端口
    /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
    /etc/rc.d/init.d/iptables save
    /etc/init.d/iptables status

    2.5.设置my.cnf文件

    Linux下用rpm包安装的MySQL是不会安装/etc/my.cnf文件的,

    至于为什么没有这个文件而MySQL却也能正常启动和作用,在点有两个说法,

    第一种说法,my.cnf只是MySQL启动时的一个参数文件,可以没有它,这时MySQL会用内置的默认参数启动,

    第二种说法,MySQL在启动时自动使用/usr/share/mysql目录下的my-medium.cnf文件,这种说法仅限于rpm包安装的MySQL,

    解决方法,只需要复制一个/usr/share/mysql目录下的.cnf文件到/etc目录,并改名为my.cnf即可。
    (我这里直接修改了复制过来的文件,把下面那段复制到了文件中)

    [client]
    #no-beep
    port=3306
    
    [mysql]
    default-character-set=utf8
    socket          = /var/lib/mysql/mysql.sock
    
    [mysqld]
    # The TCP/IP Port the MySQL Server will listen on
    port=3306
    socket          = /var/lib/mysql/mysql.sock
    
    character-set-server=utf8
    
    #默认引擎设置为INNODB,这要看你的数据库是做什么用的
    default-storage-engine=INNODB
    #最大连接数,这个说实话,我没有测出来最合理的数值
    max_connections = 500
    #下面这两个参数就是禁用缓存查询,主要是因为我的数据库大量的写操作,所以设置了cache,反而会影响性能,也是基于理论上的,所以你大可不必相信。
    query_cache_size=0
    query_cache_type=0
    
    #这几个数值,你千万要找度娘理论一下啊,我是说不清楚了
    table_open_cache=2000
    tmp_table_size=19M
    thread_cache_size = 18
    myisam_max_sort_file_size = 1G
    myisam_sort_buffer_size=30M
    key_buffer_size=8M
    read_buffer_size = 512K
    read_rnd_buffer_size = 1M
    sort_buffer_size = 512k
    
    #这个很重要了,对性能有着很大的影响,我会告诉你的。
    innodb_flush_log_at_trx_commit=2
    
    innodb_log_buffer_size=1M
    
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    innodb_buffer_pool_size=2G
    innodb_buffer_pool_instances=1
    #上面这两个参数对性能的作用我会论证给你的。
    
    #这一块参数的作用我也忘的差不多了,所以度娘吧
    innodb_log_file_size=48M
    innodb_thread_concurrency=9
    innodb_autoextend_increment=64
    innodb_buffer_pool_instances=8
    innodb_concurrency_tickets=5000
    innodb_old_blocks_time=1000
    innodb_open_files=300
    innodb_stats_on_metadata=0
    innodb_file_per_table=1
    innodb_checksum_algorithm=0
    flush_time=0
    join_buffer_size=256K
    max_connect_errors=100
    max_allowed_packet = 16M
    open_files_limit=4161
    table_definition_cache=1400
    binlog_row_event_max_size=8K
    
    #二进制的类型,这个有很大学问,稍候我也会告诉你的。
    binlog-format = MIXED
    
    #事务锁时间,这个同样学问很大。
    innodb_lock_wait_timeout = 20
    
    #事务锁级别,这个学问同样很大很大啊
    transaction-isolation = REPEATABLE-READ
    
    
    binlog_cache_size = 1M
    
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    #这个参数就是设置二进制文件的路径的,注意啊,注意啊!
    log_bin=mysql-bin
    
    server_id = 1
    
    [mysqldump]
    max_allowed_packet = 16M
    
    

    原文:https://blog.csdn.net/qing_gee/article/details/49507817
    原文:https://blog.csdn.net/qing_gee/article/details/49507817

  • 相关阅读:
    springmvc 与 springfox-swagger2整合
    [转]TensorFlow如何进行时序预测
    CORSFilter
    [转]完美解决)Tomcat启动提示At least one JAR was scanned for TLDs yet contained no TLDs
    基础开发平台要求
    ssm配置
    mysql重置root密码,并设置可远程访问
    angularjs写日期组件
    看angularjs项目的一些知识记录
    AngularJS 指令的 Scope (作用域)
  • 原文地址:https://www.cnblogs.com/wqkeep/p/11018303.html
Copyright © 2011-2022 走看看