您的位置:首页 > 数据库 > MySQL

最近自己整理的mysql方便到时候又忘了(1)

2014-12-19 19:59 190 查看

一、      Mysql5.7.4安装

安装系统:SUSE Linux Enterprise Server 11 SP2  (x86_64)

二进制包安装方法(mysql-5.7.4-m14-linux-glibc2.5-x86_64.tar.gz)

将下载的二进制压缩包放在自己指定的位置(/home/chestnuts)

以下操作都在/home/chestnuts目录下执行

1、解压

Shell> tar zxvfmysql-5.7.4-m14-linux-glibc2.5-x86_64.tar.gz    

2、建立用户组与创建用户mysql

shell>groupadd mysql

shell>useradd -g mysql mysql

3、更改名字解压后安装包名字

shell> mv mysql-5.7.4-m14-linux-glibc2.5-x86_64/ mysql

shell> cdmysql

4、对mysql用户授权该目录

shell> chown-R mysql .

shell> chgrp-R mysql .

如果文件目录改变或添加都需要重新授权

5、对数据库进行初始化

shell>./scripts/mysql_install_db--user=mysql --basedir=/home/chestnuts/mysql/ --datadir=/home/chestnuts/mysql/data/
如图所示说明数据库初始化成功

shell> chown-R root .

shell> chown-R mysql data

在support-files目录下的脚本可以直接使用 ./XXXX

拷贝脚本到/etc/ini.d方便使用

shell> cpsupport-files/mysql.server  /etc/init.d/mysql

6、配置mysql文件

shell>cpmy.cnf /etc/

shell>vi/etc/my.cnf

 

l  配置文件my.cnf(#为注释)

//------------------------------------------------------------

# For advice on how to change settings please see

#http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[client]

character-set-server = utf8

port =3306

socket=/home/chestnuts/mysql/data/mysql.sock

character_set_client = utf8

character_set_connection = utf8

character_set_results = utf8

collation_connection = utf8

 

[mysqld]

character-set-server = utf8

#default-character-set=utf8

 

# Remove leading # and set to the amount of RAM for themost important data

# cache in MySQL. Start at 70% of total RAM for dedicatedserver, else 10%.

innodb_buffer_pool_size = 128M

innodb_file_per_table=1

# Remove leading # to turn on a very important dataintegrity option: logging

# changes to the binary log between backups.

#log-bin=/home/chestnuts/mysql/log/mysql-bin.log

log-error=/home/chestnuts/mysql/log/error.log

#开启慢查询就是执行要2s以上的

long_query_time=2

slow-query-log=On

#slow_query_log_file=/home/dan/mysql/log/mysql_slow_2.log

 

# These are commonly set, remove the # and set asrequired.

 basedir =/home/chestnuts/mysql

 datadir =/home/chestnuts/mysql/data

 port = 3306

 server_id = 1

socket=/home/chestnuts/mysql/data/mysql.sock

 

# Remove leading # to set options mainly useful forreporting servers.

# The server defaults are faster for transactions andfast SELECTs.

# Adjust sizes as needed, experiment to find the optimalvalues.

#用于表间关联缓存的大小

# join_buffer_size = 128M

# Sort_Buffer_Size 是一个connection级参数,在每个connection(session)第一次需要使用这个buffer的时候,一次性分配设置的内存

# sort_buffer_size = 2M

# read_rnd_buffer_size = 2M

 

#大小写敏感

lower_case_table_names=1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES //-------------------------------------------------------------

如果有建立日志文件则需要对该文件进行mysql用户授权

shell>mkdirlog

shell>cd log

shell> chown-R mysql .

shell> chgrp-R mysql .

7、启动mysql

shell>servicemysql start或者shell>./etc/init.d/mysql start

成功的话如图所示

基本命令service mysql start|stop|restart



可能出现的问题

1、mysql用户权限没有赋予对文件的操作

2、my.cnf位置错误

3、my.cnf的配置出错

数据库data位置更改或者安装mysql位置改变则需要更改/etc/my.cnf的basedir与datadir

并且记得需要对mysql用户对新的目录进行授权(日志文件也一样)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐