您的位置:首页 > 运维架构 > Linux

CentOS7 MySQL5.6 安装问题和解决方案

2017-02-27 14:01 471 查看
1.安装CentOS7  使用CentOS-7.0-1406-x86_64-Everything.iso  默认安装全部插件和软件
2.安装过程中选择联网方式为nat (方便联网使用 yum install 访问仓库)
3.新建mysql用户和用户组
useradd mysql
groupadd mysql

4.下载MySQL-5.6.23-1.linux_glibc2.5.x86_64.rpm-bundle.tar rpm安装包
5.使用root连接ssh 并上传MySQL-5.6.23-1.linux_glibc2.5.x86_64.rpm-bundle.tar 文件到/home/mysql
   tar -xf 解压

6.删除MariaDB    rpm -qa | grep mariadb查找
执行rpm -e -nodeps 删除:

  rpm -e --nodeps mariadb-server-5.5.41-2.el7_0.x86_64

 rpm -e --nodeps   mariadb-libs-5.5.41-2.el7_0.x86_64

rpm -e --nodeps  mariadb-5.5.41-2.el7_0.x86_64

  rpm -e --nodeps mariadb-libs-5.5.35-3.el7.x86_64
 rpm -e --nodeps mariadb-5.5.35-3.el7.x86_64
  rpm -e --nodeps mariadb-server-5.5.35-3.el7.x86_64

执行
 rpm -ivh MySQL-server-5.6.23-1.linux_glibc2.5.x86_64.rpm
 rpm -ivh MySQL-client-5.6.23-1.linux_glibc2.5.x86_64.rpm

如果产error
FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
Data::Dumper
需要安装 perl-Data-Dumper
执行
    yum -y install perl-Data-Dumper

启动mysql
service mysql start

进入mysql
输入命令
mysql
use mysql
如果报错
ERROR 1045 (28000):Access denied for user 'root'@'localhost' (using password: YES) 或者

Access denied for user 'root'@'localhost' (using password: No)

那么需要给mysql的root用户设置新的密码(以下解决方案来至http://blog.csdn.net/bbirdsky/article/details/8134528)

Linux系统具体操作:

1、  停止服务:

执行:service mysql stop

2、  跳过验证:

执行:
/usr/local/mysql/bin/mysqld_safe--skip-grant-tables >/dev/null 2>&1 &

(如果mysqld_safe的位置如果和不一样需要修改,如果不清楚可以用find命令查找)。

mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit

 /etc/init.d/mysql restart

 mysql -uroot -p

Enter password: <输入新设的密码newpassword>

mysql>

3、  修改密码:

执行:

mysql
SET PASSWORD = PASSWORD('newpassword');
进入mysql
use mysql
执行
UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
flush privileges     ( 刷新MySQL权限相关的表)

exit                         (退出MySQL)

4、  重启服务:

执行:

kill all mysql                    (杀死mysql进程)

service mysql start (启动)

远程连接mysql:
 关闭linux防火墙systemctl stop firewalld.service 

配置数据库允许的远程连接的权限表
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;

grant all on *.* to 'root'@'%' identified by 'ulmu123456' with grant option;

下载
Navicat for MySQL
配置Navicat for MySQL 允许通过windows防火墙

yum配置,如果连接不上centos.org仓库
那么需要更改  /etc/resolv.conf 加上
nameserver 8.8.8.8 
nameserver 8.8.4.4 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Mysql Centos7