一、检查系统是否有自带的mysql
yum list installed |grep mysql
[root@iZ2366ycl7sZ config]# yum list installed |grep mysql
mysql.x86_64 5.1.73-5.el6_6 @base
mysql-libs.x86_64 5.1.73-5.el6_6 @base
如果有则卸载
yum -y remove mysql-libs.x86_64
二、添加mysql源
1、下载rpm包
wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm --no-check-certificate
2、安装本地mysql源
yum localinstall mysql-community-release-el6-5.noarch.rpm
3、验证是否安装成功
yum repolist all | grep mysql
[root@iZ2366ycl7sZ software]# yum repolist all | grep mysql
mysql-connectors-community MySQL Connectors Community enabled: 83
mysql-connectors-community-source MySQL Connectors Community - S disabled
mysql-tools-community MySQL Tools Community enabled: 74
mysql-tools-community-source MySQL Tools Community - Source disabled
mysql55-community MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - S disabled
mysql56-community MySQL 5.6 Community Server enabled: 493
mysql56-community-source MySQL 5.6 Community Server - S disabled
mysql57-community-dmr MySQL 5.7 Community Server Dev disabled
mysql57-community-dmr-source MySQL 5.7 Community Server Dev disabled
4、修改morning版本为5.7
安装完之后生效可用的版本为5.6,编辑配置文件
vi /etc/yum.repos.d/mysql-community.repo
把5.6的enabled=0
把5.7的enabled=1
然后保存就ok
image.png
三、安装mysql
yum install mysql-community-server
碰到的报错及解决办法
1、错误:需要libsasl2.so.2()(64bit)
解决办法:修改/etc/yum.repos.d/mysql-community.repo 源文件
[mysql57-community]
name=MySQL 5.7 Community Server
## baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
2、错误:postfix-2.10.1-6.el7.x86_64需要:libmysqlclien
原因是:存在mariadb-libs。
[root@public mysql]# rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
解决办法:卸载mariadb-libs。
yum remove mariadb-libs
四、启动mysql
service mysqld start
五、查看mysql服务状态
service mysqld status
[root@iZ2ze6hq0bb3x4th0n1rtmZ apps]# service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2020-09-28 20:15:06 CST; 14h ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 29269 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 29220 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 29273 (mysqld)
CGroup: /system.slice/mysqld.service
└─29273 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Sep 28 20:15:01 iZ2ze6hq0bb3x4th0n1rtmZ systemd[1]: Starting MySQL Server...
Sep 28 20:15:06 iZ2ze6hq0bb3x4th0n1rtmZ systemd[1]: Started MySQL Server.
六、查看mysql初始密码
grep 'temporary password' /var/log/mysqld.log
其中最后面的就是初始密码
[root@iZ2ze6hq0bb3x4th0n1rtmZ apps]# grep 'temporary password' /var/log/mysqld.log
2020-09-28T12:15:03.919151Z 1 [Note] A temporary password is generated for root@localhost: <i1F4au,pKsK
七、登录mysql并修改密码
登录:mysql -u root -p
修改密码:alter user root@localhost identified by 'passwd';
'passwd' 里,填写你的新密码 。
新修改的密码中 必须包含 大小写字母数字及符号
网友评论