[root@grewan ~]# cat /etc/redhat-release CentOS release 6.7 (Final) [root@grewan ~]# uname -a Linux grewan 2.6.32-573.26.1.el6.x86_64 #1 SMP Wed May 4 00:57:44 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux [root@grewan ~]# 注意:linux系统有不少发行版,每一个发行版安装的方法不同,具体的发行版的安装方法,请参考官方文档
安装步骤
4.1 到这个地址下载rpm包:http://dev.mysql.com/downloads/repo/yum/html
下载这个“Red Hat Enterprise Linux 6 / Oracle Linux 6 (Architecture Independent), RPM Package”对应的rpm包(CentOS6.x)系列对应的是redhat的6.x系列 这个是下载下来的rpm包的名称: mysql57-community-release-el6-8.noarch.rpm
4.2 使用下面的命令添加yum源mysql
yum localinstall mysql57-community-release-el6-8.noarch.rpm 注意:这个命令须要root权限,或者有sudo yum的权限也能够
4.3 安装MySqllinux
yum install mysql-community-server -y 注意:写本篇文章的时候,MySql的最新版本是5.7,因此不须要修改yum源中的版本信息,默认安装就是最新版。若是须要安装5.6或者5.8发布之后再安装5.7时,就须要修改安装的配置文件,具体修改方法请参考官方指南。
4.4 启动MySql 的服务sql
/etc/init.d/mysqld start 查看启动的状态 [root@grewan ~]# /etc/init.d/mysqld status mysqld (pid 4811) 正在运行... [root@grewan ~]#
mysql在安装的过程当中会默认分配一个临时的密码,可使用下面的命令查看:shell
[root@grewan ~]# sudo grep 'temporary password' /var/log/mysqld.log 2016-05-28T02:00:15.590340Z 1 [Note] A temporary password is generated for root@localhost: YhuBY6&yBOfh [root@grewan ~]#
使用这个密码登录mysql,修改默认的密码:code
mysql -uroot -p #登录mysql的shell ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; #修改密码的sql语句
配置mysql忽略表名大小写
mysql默认表名是大小写敏感的。使用下面的方式修改默认配置,让mysql忽略表名大小写:server
使用下面的命令在/etc/my.cnf文件中添加lower_case_table_names=1: [root@grewan ~]# cp /etc/my.cnf /etc/my.cnf.bak #修改配置文件前,先备份配置文件 [root@grewan ~]# echo "lower_case_table_names=1" >> /etc/my.cnf #使用这个命令修改配置文件 [root@grewan ~]# tail -1 /etc/my.cnf #使用这个命令查看配置文件是否修改为功 lower_case_table_names=1 [root@grewan ~]#
配置免密码登录mysql
每次使用mysql的时候,都要输入密码是一件很麻烦的事情,咱们在linux的家目录下能够增长一个配置文件,每次登录mysql的时候,mysql会自动读取这个文件中信息,用户不用输入帐号和密码便可登录mysql:
文件名和内容以下:htm
[root@grewan ~]# cat ~/.my.cnf #注意文件名必须为.my.cnf, 且放在家目录下,这个是默认的 [client] host=localhost user='root' password='123456Test!' [root@grewan ~]#