码迷,mamicode.com
首页 > 数据库 > 详细

centos 6.5下安装mysql

时间:2017-11-10 12:49:16      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:rem   sql   epo   root   cto   tool   tor   mysql 5.7   code   

1.检测系统是否已经安装过mysql或其依赖,若已装过要先将其删除,否则第4步使用yum安装时会报错:

1 # yum list installed | grep mysql
2 mysql-libs.i686         5.1.71-1.el6      @anaconda-CentOS-201311271240.i386/6.5
3 # yum -y remove mysql-libs.i686

 

2.从mysql的官网下载mysql57-community-release-el6-5.noarch.rpm(注意这里的el6-5即适配RHEL6.5的版本,如果下载了其它版本后面的安装过程中可能会报错):

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

 

3.安装第一步下载的rpm文件:

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

安装成功后,我们可以看到/etc/yum.repos.d/目录下增加了以下两个文件

1 # ls /etc/yum.repos.d
2 mysql-community-source.repo
3 mysql-community.repo

查看mysql57的安装源是否可用,如不可用请自行修改配置文件(/etc/yum.repos.d/mysql-community.repo)使mysql57下面的enable=1

若有mysql其它版本的安装源可用,也请自行修改配置文件使其enable=0

1 # yum repolist enabled | grep mysql
2 mysql-connectors-community MySQL Connectors Community                        13
3 mysql-tools-community      MySQL Tools Community                             18
4 mysql57-community-dmr      MySQL 5.7 Community Server Development Milesto    65

 

4.使用yum安装mysql:

yum install mysql-community-server

 

5.启动mysql服务:

service mysqld start

查看root密码:

1 # grep "password" /var/log/mysqld.log
2 2016-08-10T15:03:02.210317Z 1 [Note] A temporary password is generated for root@localhost: AYB(&-3Cz-rW

现在必须立刻修改密码,不然会报错:

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

修改密码(如果在此步报错ERROR 1819,请向下翻查看原因及解决方法):

mysql> SET PASSWORD FOR ‘root‘@‘localhost‘ = PASSWORD(‘newpass‘);

 

6.查看mysqld是否开机自启动,并设置为开机自启动:

1 chkconfig --list | grep mysqld
2 chkconfig mysqld on

 

7.修改字符集为UTF-8:

vim /etc/my.cnf

在[mysqld]部分添加:

character-set-server=utf8

在文件末尾新增[client]段,并在[client]段添加:

default-character-set=utf8

修改好之后重启mysqld服务:

service mysqld restart

 

8.登录mysql并修改密码:

# mysql -u root mysql 

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

 

centos 6.5下安装mysql

标签:rem   sql   epo   root   cto   tool   tor   mysql 5.7   code   

原文地址:http://www.cnblogs.com/fan-yuan/p/7813815.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!