标签:mysql基础
mysql的安装一般分为三种,源码安装,二进制安装,rpm安装,本文主要介绍二进制安装。
先从mysql官方网站下载mysql communicity server5.5.39版本,平台为linux-generic。
前期准备工作1和2
1. 关闭iptables
chkconfig iptables off(永久关闭)
serviceiptables stop
2. 关闭selinux
vi /etc/sysconfig/selinux
selinux=disabled
reboot
3 创建一个MySQL用户组,一个属于MySQL的用组的mysql用户
groupadd mysql
useradd -g mysql -s /sbin/nologin -d /opt/mysql mysql
查看一下用户
#id mysql
uid=500(mysql) gid=500(mysql) groups=500(mysql)
4 解压二进制
cd /opt/mysql/
tar zxvf mysql-5.5.39-linux2.6-x86_64.tar.gz
5 创建相关目录和相关文件
主要思路
/data/mysql/mysql_3306/{data, logs,tmp}
/etc/my.cnf
/usr/local/mysql->刚才解压的文件(->代表指向)
具体步骤
[root@node20 mysql]# cd /usr/local/
[root@node20 local]# ln -s /opt/mysql/mysql-5.5.39-linux2.6-x86_64 mysql
[root@node20 local]# ls -l mysql
lrwxrwxrwx 1 root root 39 Sep 11 20:56 mysql ->/opt/mysql/mysql-5.5.39-linux2.6-x86_64
cd /data
mkdir mysql
[root@node20 mysql]# mkdir mysql_3306
[root@node20 mysql]# cd mysql_3306/
[root@node20 mysql_3306]# mkdir data
[root@node20 mysql_3306]# mkdir logs
[root@node20 mysql_3306]# mkdir tmp
6 更改权限
chown -R mysql:mysql /data/mysql/
chown -R mysql:mysql /usr/local/mysql/
7 加环境变量,解决找不到mysql命令的问题
Vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
8 依赖的lib库是否安全了
# ldd /usr/local/mysql/bin/mysqld
9 配置文件修改
wget http://imysql.com/wp-content/uploads/2014/08/my.cnf-sample.txt
mv my.cnf-sample.txt /etc/my.cnf
datadir = /home/mysql –>datadir =/data/mysql/mysql_3306/data
socket = /tmp/mysql.sock
:%s/home\/mysql/data\/mysql\/mysql_3306\/data/g
innodb_buffer_pool_size = 1G -> innodb_buffer_pool_size = 100M
innodb_log_files_in_group = 2 -> innodb_log_files_in_group = 3
10 初始化一个数据库
cd /usr/local/mysql/
初始化数据库一定要在basedir 下进行
./scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf
如果出现错误
经验总结: 初始化,启动 都要关注error log
11 启动Mysql
cp support-files/mysql.server /etc/init.d/mysql
启动:
/etc/init.d/mysql start
出现如下错误:
socket = /tmp/mysql.sock
12 mysql登入出现一些错误
vi /etc/my.cnf
socket=/tmp/my.sock
13 查看我们的MySQL进程是否存在及监听端口
# ps axu|grep mysqld
# netstat -nalp | grep “3306”
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
2689/mysqld
14 查看用户和host地址
"root@localhost Sat Sep 13 16:21:09 2014 16:21:09 [(none)]>select user,host,password from mysql.user;
+------+---------------------+----------+
| user | host | password |
+------+---------------------+----------+
| root | localhost | |
| root | centos5.localdomain | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | centos5.localdomain | |
+------+---------------------+----------+
6 rows in set (0.00 sec)
本文出自 “dba天空” 博客,请务必保留此出处http://9425473.blog.51cto.com/9415473/1557669
标签:mysql基础
原文地址:http://9425473.blog.51cto.com/9415473/1557669