防伪码:没有相当程度的孤独是不可能有内心的平和。
1、测试环境
主机名
IP
系统
MySQL版本
MySQL-00
192.168.10.23
CentOS release 6.9 (Final)
5.5.56
2、部署
2.1 卸载之前版本
rpm -qa|grep mysql
rpm -e --nodeps mysql-libs-5.1.73-8.el6_8.x86_64
2.2 安装依赖包和cmake
yum -y install ncurses-devel libaio-devel cmake
2.3 创建用户和目录
useradd mysql -s /sbin/nologin -M
mkdir /app
2.4 编译安装
2.4.1 解压
cd /opt
tar zxf mysql-5.5.56.tar.gz
cd mysql-5.5.56
2.4.2 编译安装
cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql-5.5.56 -DMYSQL_DATADIR=/app/mysql-5.5.56/data -DMYSQL_UNIX_ADDR=/app/mysql-5.5.56/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_ZLIB=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DWITH_DEBUG=0
make && make install
2.4.3 创建tmp目录及配置文件
mkdir /app/mysql-5.5.56/tmp
cd /app/mysql-5.5.56
cp support-files/my-small.cnf /etc/my.cnf
chown -R mysql.mysql /app/mysql-5.5.56
chmod -R 1777 /app/mysql-5.5.56/tmp
2.4.4 初始化
cd /app/mysql/scripts/
./mysql_install_db --basedir=/app/mysql-5.5.56/ --datadir=/app/mysql-5.5.56/data/ --user=mysql
2.4.5 启动脚本
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
ln -s /app/mysql-5.5.56 /app/mysql
cp /app/mysql-5.5.56/bin/* /usr/local/sbin/
chkconfig --add mysqld
chkconfig mysqld on
2.4.6 配置UTF-8字符集
sed -i '22a default-character-set=utf8' /etc/my.cnf
sed -i '38a character-set-server=utf8' /etc/my.cnf
sed -i '83a default-character-set=utf8' /etc/my.cnf
查看字符集:
mysql> show variables like 'character%';
+--------------------------+-----------------------------------+
| Variable_name | Value |
+--------------------------+-----------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /app/mysql-5.5.56/share/charsets/ |
+--------------------------+-----------------------------------+
8 rows in set (0.00 sec)
2.4.7 修改密码
mysqladmin -uroot password