准备
mysql5.5需要使用cmake安装
下载:
cmake-3.2.2-Linux-x86_64.tar.gz
解压
tar -zxvf cmake-3.2.2-Linux-x86_64.tar.gz
1、创建mysql用户
groupadd mysql useradd -g mysql mysql
2、目录创建
mkdir -p /opt/mysql chown -R mysql:mysql /opt/mysql cd /opt/mysql mkdir data mkdir etc
3、解压安装包
tar -zxvf mysql-5.5.22.tar.gz
4、编译
../cmake-3.2.2-Linux-x86_64/bin/cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/opt/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci make make install
5、初始化数据库
cd /opt/mysql/scripts chmod +x mysql_install_db ./mysql_install_db --basedir=/opt/mysql --datadir=/opt/mysql/data --user=mysql
6、设置mysql开机启动
cp /opt/mysql/support-files/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql
7、配置环境变量
/etc/profile export PATH=/opt/mysql/bin:$PATH
8、启动mysql
/etc/init.d/mysql start mysql -u root -p
9、重启、关闭
/etc/init.d/mysql restart /etc/init.d/mysql stop
10、设置root密码
/opt/mysql/bin/mysqladmin -u root password mysql
11、登录mysql
mysql -u root -p mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.02 sec)
12权限
使其他主机能够通过root用户连接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION;
13修改字符集
ALTER DATABASE form DEFAULT CHARACTER SET = gbk;
14创建数据库
CREATE DATABASE forum DEFAULT CHARACTER SET gbk;