CentOS 5.5 下安装 Mysql 5.5

 

MySQL 5.5 使用InnoDB作为默认的数据库存储引擎
下载: http://www.mysql.com/downloads/

1.    mysql用户

groupadd mysql
useradd -g mysql -s /bin/false -M mysql

2.    mysql 5.5需要用 cmake来编译:
安装cmake,及相关包:

yum install  -y \
cmake.x86_64 \
gcc \
gcc-c++  \
ncurses-devel.x86_64 \
bison.x86_64 \
libaio.x86_64
 

3.     解压 mysql5.5.tar.gz ,编译:

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysqldata \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
 

然后执行:

Make && make install

如果想重新 make,需清除cmake用:

make clean
rm -f CMakeCache.txt
 

4.    设置:

cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /usr/local/mysql/bin/
chmod 755 /usr/local/mysql/bin/mysql.server
chown -R mysql .root  /usr/local/mysql
cd /usr/local/mysql
mkdir /data/mysqldata
scripts/mysql_install_db --user=mysql
cp –rpf /usr/local/mysql/data/* /data/mysqldata

 

5.     添加相对路径:

echo "  export PATH=$PATH:/usr/local/mysql/bin"  >> /etc/profile
source /etc/profile

6.    启动和停止 Mysql:

mysql.server   start
mysql.server   stop

7.    查看是否有 3306端口:

netstat -anp | grep LISTEN

8.    编辑 /etc/my.cnf,添加红色字体:

[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
log-bin=mysql-bin
expire_logs_days = 5

9.    进入 Mysql 

mysql

查看 mysql状态,字符集最好都是utf8
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.5.21, for Linux (x86_64) using EditLine wrapper
Connection id:           2
Current database:
Current user:            root@localhost
SSL:                     Not in use
Current pager:           stdout
Using outfile:           ''
Using delimiter:         ;
Server version:          5.5.21-log Source distribution
Protocol version:        10
Connection:              Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn. characterset:    utf8
UNIX socket:             /usr/local/mysql/mysql.sock
Uptime:                  26 min 45 sec
 

10.Mysql常用命令 :

 
 

你可能感兴趣的:(mysql,数据库,安装,centos,local)