MySQL 完整安装配置
一.创建用户和路径
1. 创建 MySQL 用户组和用户
# groupadd mysql
# useradd -g mysql mysql
2.创建数据存储路径
# mkdir /data/dbfile
# chown -R mysql.mysql /data/dbfile
二.安装 mysql 5.x.x.tar.gz
1.编译
默认字符集
扩展字符集
安装Innodb
指定数据存储路径
指定系统配置文件路径
# ./configure --prefix=/data/mysql5 --with-charset=utf8 --with-extra-charsets=all --with-plugins=partition,heap,innobase,myisam --enable-thread-safe-client --without-docs --with-pthread --enable-static --with-big-tables --without-debug --localstatedir=/data/dbfile --sysconfdir=/etc ----infodir=/data/mysql5
# make
# make install
2.拷贝 my.cnf
# cp mysql-5.1.31/support-files/my-medium.cnf /etc/my.cnf
3.初始化数据库
# mysql5131/bin/mysql_install_db --user=mysql
4.启动 MySQL 服务
# mysql5/bin/mysqld_safe --user=mysql &
5.停止 MySQL 服务
# mysql5/bin/mysqladmin shutdown
6.MySQL 调优 my.cnf
包含Innodb配置
7.删除旧 Innodb 日志文件
# rm /data/dbfile/ibdata1 ib_logfile0 ib_logfile1
8.重启 MySQL
9.查看 Innodb 运行状态
mysql > show variables like '%innodb%';
+---------------------------------+------------------------+
| Variable_name | Value |
+---------------------------------+------------------------+
| have_innodb | YES |
+---------------------------------+------------------------+
三.创建数据库
mysql > GREATE DATABASE aa;
【查看 aa 默认字符集】
mysql > show table status from test like '%aa%'G;
*************************** 1. row ***************************
Name: aa
Engine: InnoDB
Version: 10
Row_format: Fixed
Rows: 8
Avg_row_length: 7
Data_length: 56
Max_data_length: 1970324836974591
Index_length: 1024
Data_free: 0
Auto_increment: NULL
Create_time: 2009-04-13 10:28:14
Update_time: 2009-04-13 11:51:37
Check_time: NULL
Collation: gbk_chinese_ci
Checksum: NULL
Create_options:
Comment:
四.设置 MySQL 服务开机自启动
通过 service mysql start | stop | restart 管理 mysql 服务
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld 设置使mysql每次启动都能自动运行
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on
# service mysqld start //启动mysqld服务
五.设置全局登录
通过 # mysql 直接登录
export PATH=$PATH:/data/mysql5/bin
[@more@]