CentOS7 64位安装mysql教程
1.先检查系统是否装有mysql
rpm -qa | grep mysql
2.执行以下命令更新Mariadb数据库
yum install mysql
yum remove mysql
3.下载mysql的repo源
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
4.安装mysql-community-release-el7-5.noarch.rpm包
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装结果:获得两个mysql的yum repo源:/etc/yum.repos.d/mysql-community.repo,/etc/yum.repos.d/mysql-community-source.repo
5.安装mysql
sudo yum install mysql-server
最后:重置密码
命令:
use mysql;
update user set password=password('123456') where user='root';
重启mysql服务生效:
命令:systemctl restart mysql
其他:
1)为root添加远程连接的能力
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
2)查询数据库编码格式,确保是 UTF-8
命令:show variables like "%char%";
set names utf8;
安装提示:
如果报错,内容含有
Error: Package: mysql-community-libs-5.6.35-2.el7.x86_64 (mysql56-community)
Requires: libc.so.6(GLIBC_2.17)(64bit)
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)
Requires: libc.so.6(GLIBC_2.17)(64bit)
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)
Requires: systemd
Error: Package: mysql-community-server-5.6.35-2.el7.x86_64 (mysql56-community)
Requires: libstdc++.so.6(GLIBCXX_3.4.15)(64bit)
Error: Package: mysql-community-client-5.6.35-2.el7.x86_64 (mysql56-community)
Requires: libc.so.6(GLIBC_2.17)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
解决方案:
#yum install glibc.i686
# yum list libstdc++*
登录时有可能报这样的错:ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2),原因是/var/lib/mysql的访问权限问题
解决方案:
下面的命令把/var/lib/mysql的拥有者改为当前用户:
sudo chown -R 当前用户组:当前用户 /var/lib/mysql
附:
① 更改文件拥有者 (chown )
[root@linux ~]# chown 账号名称 文件或目录
② 改变文件的用户组用命令 chgrp
[root@linux ~]# chgrp 组名 文件或目录
③ 对于目录权限修改之后,默认只是修改当前级别的权限。如果子目录也要递归需要加R参数
Chown -R : 进行递归,连同子目录下的所有文件、目录
注意:修改需要重启服务!