1. ⾸先检查系统⾥是否存在mysql库⽂件
rpm -qa | grep mysql
如果存在mysql-lib则删除:
rpm -e --nodeps mysql-libs
2. 解压缩mysql-bundle包
tar -xvf mysql-5.7.23-1.el6.x86_64.rpm-bundle.tar
按顺序安装:
rpm -ivh mysql-community-common-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.16-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.16-1.el6.x86_64.rpm
安装完后,使⽤命令service mysqld start启动MySQL服务。
3. 使⽤以下命令: grep ‘temporary password’ /var/log/mysqld.log 取得初始密码
修改密码:
mysql_secure_installation
4. 修改字符集为UTF-8:
vim /etc/my.cnf
在[mysqld]部分添加: character-set-server=utf8
在⽂件末尾新增[client]段,并
在[client]段添加: default-character-set=utf8
5. 修改好之后重启mysqld服务: service mysqld restart 查看修改结果:
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 | /usr/share/mysql/charsets/ |
-------------------------- ----------------------------
8 rows in set (0.00 sec)