CentOS Mysql安装
yum list | grep mysql
yum install mysql-server
Mysql 配置
目的:把data文件和log文件移动到另外一张磁盘上.如下:
注意:最好先不要执行 service mysqld start命令
1. 移动 /var/lib/mysql 目录到指定目录 , 这里为 /data/mysql目录
mv /var/lib/mysql /data/
2. 修改 /data/mysql目录权限
chown -R mysql:mysql /data/mysql
3. 修改 /etc/my.cnf文件内容
[mysqld]
datadir=/data/mysql
socket=/data/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# charset
default-character-set=utf8
default-collation=utf8_general_ci
character-set-server=utf8
collation-server=utf8_general_ci
init-connect='SET NAMES utf8'
[mysqld_safe]
log-error=/data/mysql/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
default-character-set=utf8
socket=/data/mysql/mysql.sock
注意:mysqld 中socket的配置必须和 client 中socket的配置一致.
4. 创建用户并赋予权限
create user ‘username’ identified by ‘password’;
grant all on *.* to username;
5. 启动
service mysqld start