第一步:
yum -y install mysql-server 第二步:修改配置文件[root@sample ~]#vim /etc/my.cnf ← 编辑MySQL的配置文件[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Default to using old password format for compatibility with mysql 3.x# clients (those using the mysqlclient10 compatibility package).old_passwords=1 ← 找到这一行,在这一行的下面添加新的规则,让MySQL的默认编码为UTF-8default-character-set = utf8 ← 添加这一行然后在配置文件的文尾填加如下语句:
[mysql]default-character-set = utf8第三步:设置开机启动
[root@sample ~]# chkconfig mysqld on ← 设置MySQL服务随系统启动自启动[root@sample ~]# chkconfig --list mysqld ← 确认MySQL自启动 mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← 如果2--5为on的状态就OK第四步:建立用户mysql
chattr -i /etc/groupchattr -i /etc/passwdchattr -i /etc/shadowchattr -i /etc/gshadowuseradd mysql chattr +i /etc/groupchattr +i /etc/passwdchattr +i /etc/shadowchattr +i /etc/gshadow第五步:设置权限
chown mysql /var/run/mysqld/cd /var/lib/mysql
chown mysql -R *cd –第六步:
mysql_install_db --user=mysql --ldata=/var/lib/mysql第七步:开启服务
[root@sample ~]# /etc/rc.d/init.d/mysqld start ← 启动MySQL服务