centos6.4下mysql5.6.11安装

1.根据系统内核选择mysql版本

uname -a //查看内核版本

2.在这里我选则mysql5.6.11版本使用的是cmake

前提先要安装cmake

3创建安装目录:

mkdir /usr/lamp/mysql

mkdir /usr/lamp/mysql/data

 

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/lamp/mysql \
-DMYSQL_DATADIR=/usr/lamp/mysql/data \
-DSYSCONFDIR=/etc/mysql \   #我的配置文件目录
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DMYSQL_TCP_PORT=3306 \

make &&makeinstall   //编译安装

3.报错的话查看错误日志

默认在安装的mysql目录下:mysql/data/.... .err

 

根据日志文件显示,首先检查运行权限,再看一下/tmp/mysqld.sock ,发现/tmp/mysqld.sock ck目录下并没有该文件,是否是没有权限 写/var目录?OK,那就用root用户运行一下safe_mysqld,启动正常。使用mysql连接数据库,提示错误,连接不到数据库服务器, /tmp目录下没有mysql.sock这个文件,到这里,基本清楚了Mysql客户端和服务器端在本机的通信方式了,通过一个名为mysql.sock 文件来进行初始化通信的,因此该文件所存放的目录必须双方都有权限可以访问到,而且服务器在启动时需要写该文件,如果my.cnf中这两项配置不正确,就 会出现Permission denied等类似错误。

 

创建用户组,用户(为了安全)
groupadd mysql
useradd -g mysql mysql

#mysql配置文件
cp support-files/my-default.cnf  /etc/mysql/my.cnf

#使用mysql用户创建授权表
scripts/mysql_install_db --user=mysql

#‘./’或者'.'表示当前目录所有
chown -R root . #mysql下 文件拥有者改为root
chown -R mysql data  #data文件夹拥有者改为mysql
chgrp -R mysql . #mysql下 文件所有组改为mysql

#启动mysql服务进程
#&表示后台执行
bin/mysqld_safe --user=mysql &
bin/mysql -u root

 

#root用户没密码可直接登录
删除多余用户,
delete from mysql.user where host='localhost' and user='';
flush privileges; #刷新授权表
set password for 'root'@'localhost'=password('123456');


#在mysql客户端登录
/bin/mysql -u root -h localhost -p #回车输入密码
#关闭mysql数据库
bin/mysqladmin -u root -p shutdown

 

出错查看错误日志

 

官方给的安装方法

http://www.linuxfromscratch.org/blfs/view/svn/server/mysql.html

安装参考文章:

http://www.cnblogs.com/vicowong/archive/2011/01/27/1946453.html

http://www.linuxidc.com/Linux/2012-10/72754.htm

http://wenku.baidu.com/view/9775e9795acfa1c7aa00cc47.html

http://wurhuangfeng.blog.163.com/blog/static/3517824120120122036352/

http://ylq365.iteye.com/blog/1186273

http://www.ixiaohuaxiaocao.net/

 

 

 

配置文件内容:根据自己的情况配置

 

 
 

Create basic
/etc/mysql/my.cnf
using the following command as the
root
user:

install -v -dm 755 /etc/mysql &&
cat > /etc/mysql/my.cnf << "EOF"

# Begin /etc/mysql/my.cnf # The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = /run/mysqld/mysqld.sock # The MySQL server [mysqld] port = 3306 socket = /run/mysqld/mysqld.sock datadir = /srv/mysql skip-external-locking key_buffer = 16M max_allowed_packet = 1M sort_buffer_size = 512K net_buffer_length = 16K myisam_sort_buffer_size = 8M # Don't listen on a TCP/IP port at all. skip-networking # required unique id between 1 and 2^32 - 1 server-id = 1 # Uncomment the following if you are using BDB tables #bdb_cache_size = 4M #bdb_max_lock = 10000 # Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /srv/mysql #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /srv/mysql # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 16M #innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 5M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash # Remove the next comment character if you are not familiar with SQL #safe-updates [isamchk] key_buffer = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout # End /etc/mysql/my.cnf
EOF



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mumu_wangwei

主修"红尘道--红尘练心"

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值