安装MySQL教程详解-创新互联-成都快上网建站

安装MySQL教程详解-创新互联

本文主要给大家介绍安装MySQL 教程详解,希望可以给大家补充和更新些知识,如有其它问题需要了解的可以持续在创新互联行业资讯里面关注我的更新文章的。

成都创新互联公司主要从事做网站、网站制作、网页设计、企业做网站、公司建网站等业务。立足成都服务漯河,十多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792

 本次主要是mysql-5.5.54 的安装

基础环境为:

                  centos 6.8 

 一、下载mysql-5.5.54 安装包

    创建软件存放目录

                    mkdir /home/softwares/

                    cd  /home/softwares/

          wget  http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.54.tar.gz

二、安装mysql 依赖包

                    yum install -y cmake;

                    yum install -y gcc gcc-c++ ;

                    yum install -y ncurses-devel.x86_64 ;

                    yum install -y cmake.x86_64 ;

                    yum install -y libaio.x86_64 ;

                    yum install -y bison.x86_64 ;

                    yum install -y gcc-c++.x86_64;

                    yum install -y perl-Module-Build;

                    yum install -y libtool zilib-devel ;

                    yum install -y libaio.x86_64;

                    yum install -y perl.x86_64;

                    yum install -y perl-Module-Pluggable.x86_64;

                    yum install -y perl-Pod-Escapes.x86_64;

                    yum install -y perl-Pod-Simple.x86_64;

                    yum install -y perl-libs.x86_64;

                    yum install -y perl-version.x86_64 ;

                    yum install –y openssl openssl-devel ncurses ncurses-devel;

            2、创建用户和组分区

                  groupadd mysql

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

            3、解压mysql-5.5.54.tar.gz

                  tar -zxvf mysql-5.5.54.tar.gz && cd mysql-5.5.54/  && chmod +x *

            4、编译安装

安装MySQL 教程详解

cmake \ ##相当于config
-DCMAKE_INSTALL_PREFIX=/u01/app/mysql/db \  ##数据库安装的目录
-DSYSCONFDIR=/u01/app/mysql/db/etc \    ##数据库安装的配置文件,不用原来的默认文件可以避免多次升级的时候读取错误的配置文件
-DMYSQL_DATADIR=/u01/data/mysql/db/data \ ##数据库默认存放库表存放的位置
-DWITH_MYISAM_STORAGE_ENGINE=1 \ 
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/u01/app/mysql/db/mysql.sock \ ##本地通信日志
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \

       make  install

          5、编写配置文件

         cd /u01/app/mysql/db/  &&  mkdir etc && cd etc

              mkdir etc

                vi my.cnf

cat my.cnf

[mysqld]

#########data###########

user=mysql

basedir = /u01/app/mysql/db

datadir = /u01/app/mysql/data

innodb_log_group_home_dir=/u01/app/mysql/engine/innolog

innodb_log_file_size = 50M

innodb_data_home_dir=/u01/app/mysql/engine/innodata

#innodb_data_file_path = ibdata1:100M;ibdata2:150M:autoextend

innodb_data_file_path = ibdata1:100M:autoextend

log-bin = /u01/app/mysql/log/mysql-binlog

log-bin-index = /u01/app/mysql/log/mysql-bin.index

binlog_cache_size = 32M

max_binlog_size=512M

binlog_format=row

innodb_file_per_table=1

log-error = /u01/app/mysql/mysql-error.log

pid-file = /u01/app/mysql/mysql.pid

skip-name-resolve

socket=/u01/app/mysql/mysql.sock

############pool#########

#*******skip-innodb*********

innodb_additional_mem_pool_size = 64M

innodb_buffer_pool_size=256M

innodb_write_io_threads = 8

innodb_read_io_threads = 8

innodb_thread_concurrency = 16

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 16M

innodb_log_file_size = 512M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

port=3306

server-id= 1

# *** global cache ***

read_buffer_size = 32M

read_rnd_buffer_size = 128M

sort_buffer_size = 64M

join_buffer_size = 64M

# *** query cache ***

query_cache_size = 128M

query_cache_limit = 4M

# *** bin log ***

#log_slave_updates

log_warnings

###########others#########

#***transaction***

default-storage-engine = INNODB

transaction_isolation = REPEATABLE-READ

# *** thread ***

thread_cache_size = 16

thread_stack = 512K

#*** network ***

back_log = 512

#skip-networking

max_connections = 3000

max_connect_errors = 30

table_open_cache = 4096

max_allowed_packet = 32M

max_heap_table_size = 512M

#*** char set ***

character-set-server = utf8

#explicit_defaults_for_timestamp = true

# *** tmp table ***

tmp_table_size = 128M

# *** slow query log ***

slow_query_log

long_query_time = 10

[mysqldump]

quick

max_allowed_packet = 32M

[mysql]

auto-rehash

[myisamchk]

key_buffer_size = 12M

sort_buffer_size = 12M

read_buffer = 32M

write_buffer = 32M

[mysqlhotcopy]

interactive-timeout

[client]

socket=/u01/app/mysql/mysql.sock

port=3306

          6、将mysql启动脚本脚本命令复制到/etc/init.d/

                cp /u01/app/mysql/db/support-files/mysql.server /etc/init.d/mysqld && chmod +x                 /etc/init.d/mysqld

                chmod +x /etc/init.d/mysqld

      7、根据my.cnf 创建目录他不会自动创建目录

             mkdir -p /u01/app/mysql/data/engine/innolog

        mkdir -p /u01/app/mysql/data/engine/innodata

               mkdir -p /u01/app/mysql/data/mysql-binlog

              mkdir -p /u01/app/mysql/log/

               chown mysql. /u01/app/mysql/ -R

                cd /u01/app/mysql/db

         8、初始化语句数据库安装指定的目录,数据库默认存放目录

            ./scripts/mysql_install_db --basedir=/u01/app/mysql/db --datadir=/u01/app/mysql/data --user=mysql

          更改环境变量

            vim ~/.bash_profile

            PATH=$PATH:$HOME/bin:/u01/app/mysql/db/bin/

            环境变量生效

             source ~/.bash_profile

            如果报错:

 /etc/init.d/mysqld start

 配置文件的问题

 Starting MySQL... ERROR! The server quit without updating PID file (/data/mysql/mysql.pid).

一般需要自己查询配置文件是否设置的参数过大或者过小,查看机器内存是否过小,如果都是可以的请删除除了db 文件之外的所有 然后重新创建目录

             ##########启动成功之后设置密码###########

                mysqladmin -uroot password "123456"

看了以上关于安装MySQL 教程详解,希望能给大家在实际运用中带来一定的帮助。本文由于篇幅有限,难免会有不足和需要补充的地方,如有需要更加专业的解答,可在官网联系我们的24小时售前售后,随时帮您解答问题的。

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页题目:安装MySQL教程详解-创新互联
标题来源:http://kswjz.com/article/pcojp.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流