近日在需要在公司老开发环境安装mysql
于是乎一顿操作
①下载并安装MYSQL官方的 Yum Repository(此处注意版本 centos7以上的版本用的是el7-5 这里是centos6.8 所以使用el6-9)
wget -i -c wget https://dev.mysql.com/get/mysql57-community-release-el6-9.noarch.rpm
rpm -Uvh mysql57-community-release-el6-9.noarch.rpm
②开始安装
yum -y install mysql-community-server
霍霍 报错
--> Finished Dependency Resolution
Error: Package: mysql-community-server-5.7.27-1.el7.x86_64 (mysql57-community)
Requires: libsasl2.so.3()(64bit)
Error: Package: mysql-community-client-5.7.27-1.el7.x86_64 (mysql57-community)
Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
Error: Package: mysql-community-libs-5.7.27-1.el7.x86_64 (mysql57-community)
Requires: libc.so.6(GLIBC_2.14)(64bit)
Error: Package: mysql-community-client-5.7.27-1.el7.x86_64 (mysql57-community)
Requires: libc.so.6(GLIBC_2.14)(64bit)
Error: Package: mysql-community-server-5.7.27-1.el7.x86_64 (mysql57-community)
Requires: systemd
Error: Package: 2:postfix-2.6.6-6.el6_7.1.x86_64 (@anaconda-CentOS-201605220104.x86_64/6.8)
Requires: libmysqlclient.so.16()(64bit)
Removing: mysql-libs-5.1.73-8.el6_8.x86_64 (installed)
libmysqlclient.so.16()(64bit)
Obsoleted By: mysql-community-libs-5.7.27-1.el7.x86_64 (mysql57-community)
Not found
Error: Package: mysql-community-server-5.7.27-1.el7.x86_64 (mysql57-community)
Requires: libc.so.6(GLIBC_2.17)(64bit)
Error: Package: mysql-community-server-5.7.27-1.el7.x86_64 (mysql57-community)
Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
执行
yum clean all
继续安装
成功
附赠继续安装步骤
如果是Centos7.5 安装流程 如下
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
下载速度过慢解决方案:https://www.cnblogs.com/downmoon/p/11896158.html?spm=a2c6h.13066369.0.0.29f62a995OI4yF
③安装完成 启动MYSQL
systemctl start mysqld.service
④从日志中找出密码
grep "password" /var/log/mysqld.log
⑤用刚才的密码进入数据库
mysql -uroot -p
⑤修改密码,其中new password是新密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
如果提示
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
则是密码策略过高
可以尝试复杂密码或者使用简单策略
set global validate_password_policy=0
⑥开启远程访问
grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;
(如开放所有IP 将IP地址换成%)
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
⑦然后输入下面命令
mysql> flush privileges;
⑧修改为数据库为utf8mb4格式
vim /etc/my.cnf
添加如下代码
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
⑨重新启动mysql
systemctl restart mysqld.service