Centos6.5 安装MySQL 5.7
⾸先检查系统⾥是否存在mysql库⽂件
rpm -qa | grep mysql
如果存在mysql-lib则删除:
rpm -e --nodeps mysql-libs
解压缩mysql-bundle包
tar -xvf mysql-5.7.23-1.el6.x86_64.rpm-bundle.tar
按顺序安装:
rpm -ivh mysql-community-common-5.7.23-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.23-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.23-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.23-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.23-1.el6.x86_64.rpm
安装完后,使⽤命令service mysqld start启动MySQL服务。
使⽤以下命令: grep ‘temporary password’ /var/log/mysqld.log 取得初始密码
修改密码:
mysql_secure_installation
1.输入新密码
Press y|Y for Yes, any other key for No: y
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
修改字符集为UTF-8:
vim /etc/my.cnf
在[mysqld]部分添加: character-set-server=utf8 在⽂件末尾新增[client]段,并
在[client]段添加: default-character-set=utf8
修改好之后重启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)