基础环境:Redhat6
一、创建MySQL组及用户
groupadd mysql
useradd -g mysql mysql -s /sbin/nologin -M mysql
二、创建mysql安装目录
mkdir -p /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /bmcdb
三、解压安装MySQL
tar -xvf mysql-5.5.36-linux2.6-x86_64.tar
cd /soft/src/mysql-5.5.36-linux2.6-x86_64
#安装MySQL
rpm -ivh MySQL-server-5.5.36-1.el6.x86_64.rpm
rpm -ivh rpm -ivh MySQL-client-5.5.36-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.5.36-1.el6.x86_64.rpm
rpm -ivh MySQL-shared-compat-5.5.36-1.el6.x86_64.rpm MySQL-shared-5.5.36-1.el6.x86_64.rpm
四、修改root口令
mysqladmin -u root password
初始口令设置为123abc
五、创建并授权webapp账号可远程访问
grant all privileges on test.* to webapp@"%" identified by '123abc' with grant option;
#刷新权限
flush privileges;
六、设置mysql在系统235模式下随机启动
chkconfig --level 235 mysql on
七、创建数据库
create database
grant all privileges on bcmdb.* to webapp@"%" identified by '123abc' with grant option;
八、修改数据库主目录
#create database bcmdb
#service mysql stop
#cd /var/lib
#cp -arp mysql /bcmdb/db1/mysql
#vi my.cnf
[mysqld]
#socket = /var/lib/mysql/mysql.sock
socket = /bcmdb/db1/mysql/mysql.sock
datadir=/bcmdb/db1/mysql
九、修改数据库编码
[client]
default_character_set=utf8
[mysqld]
character_set_server=utf8
collation_server=utf8_general_ci
init_connect='SET NAMES utf8'
#show variables like '%char%';
修改数据库编码的其他方法:
alter database bcmdb default character set utf8 collate utf8_general_ci;
十、测试插入中文字符是否正常显示
#mysql -u root -p 123abc
#use test;
#create table t01(name char(10));
#insert into t01 values("冯");
#select * from t01;
阅读(6218) | 评论(0) | 转发(1) |