MYSQL5.6版本详细安装步骤

1、查看系统中是否自带安装mysql

yum list installed | grep mysql

2、删除系统自带的mysql及其依赖(防止冲突)

yum -y remove mysql-libs.x86_64

3、安装wget命令

yum install wget -y 

4、给CentOS添加rpm源,并且选择较新的源

wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm

5、安装下载好的rpm文件

 yum install mysql-community-release-el6-5.noarch.rpm -y

6、安装成功之后,会在/etc/yum.repos.d/文件夹下增加两个文件

cd /etc/yum.repos.d/

7、修改mysql-community.repo文件

vi mysql-community.repo
//修改配置文件
# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
​
# Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
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
​

8、使用yum安装mysql

yum install mysql-community-server -y

9、启动mysql服务并设置开机启动

#启动mysql服务
service mysqld start
#设置mysql开机启动
chkconfig mysqld on

10、获取mysql的临时密码

grep "password" /var/log/mysqld.log

11、使用临时密码登录

mysql -uroot -p
#输入密码

12、修改密码

set global validate_password_policy=0;
set global validate_password_length=1;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';

13、修改远程访问权限

grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
flush privileges;

14、设置字符集为utf-8

#在[mysqld]部分添加:
character-set-server=utf8
#在文件末尾新增[client]段,并在[client]段添加:
default-character-set=utf8

你可能感兴趣的:(mysql,数据库,centos)