centos7安装mysql5(完整可行版)
一个很有趣的个人博客,不信你来撩 fangzengye.com
特别感谢这位老兄,我安装了两天都快要绝望了,是他给了我光明,我安装成功了,这两天上网查了好多资料都好复杂都没安装成功。
https://www.cnblogs.com/lzhdonald/p/12511998.html
另外一篇安装mysql8的链接
安装过程正式开始
mysql5.7版本https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
下载
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
解压
tar -xvf mysql-5.7.29-1.el7.x86_64.rpm-bundle.tar
卸载系统自带的的mariadb-lib
查看命令
rpm -qa|grep mariadb
输出
mariadb-libs-5.5.60-1.el7_5.x86_64
卸载命令
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
- 为了避免出现权限问题,给mysql解压文件所在目录赋予最大权限
chmod -R 777 mysql
安装文件次序
rpm -ivh mysql-community-common-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.29-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.29-1.el7.x86_64.rpm
可能会出现这样错误
error: Failed dependencies: libaio.so.1()(64bit) is needed by MySQL-server-5.5.25a-1.rhel5.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.5.25a-1.rhel5.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.5.25a-1.rhel5.x86_64
解决命令如下:
yum install libaio
这样就ok了,就可以继续安装mysql了。
如果安装过程中出现这个错误就在后面添加
--force --nodeps
这可能是由于yum安装了旧版本的GPG keys造成的

配置数据库
vim /etc/my.cnf
- 进入文件内容
- 按 i 进入编辑状态
- 添加下面
skip-grant-tables
character_set_server=utf8
init_connect='SET NAMES utf8'
- 按esc退出编辑状态
- 输入
:wq保存并退出

命令解释
skip-grant-tables:跳过登录验证character_set_server=utf8:设置默认字符集UTF-8
init_connect='SET NAMES utf8':设置默认字符集UTF-8
启动MySQL服务器
- 设置开机启动
systemctl start mysqld.service
- 启动mysql
mysql
设置密码
update mysql.user set authentication_string=password('123456') where user='root';
立即生效
flush privileges;
退出
exit
退出mysql并停止mysql服务
systemctl stop mysqld.service
重启mysql服务
systemctl start mysqld.service
再次登录mysql
mysql -uroot -p123456
我的个人博客fangzengye.com, 欢迎来撩哦!
原文博主: 热衷开源的宝藏Boy
版权声明: 自由转载-非商用-禁止演绎-保持署名| CC BY-NC-ND 3.0
浙公网安备 33010602011771号