mysql的下载: https://dev.mysql.com/downloads/mysql/5.6.html#downloads
自行下载想要的版本,一般下载
#解压
tar -zxvf xxx
#将xxx文件下的内容全部拷贝到。。 /.就是文件夹下的全部内容
cp -r xxx/. /usr/local/mysql
#添加用户组
groupadd mysql
#添加用户组
groupadd mysql
cd /usr/local/mysql/
#创建数据日志目录
mkdir ./data/mysql
给root用户赋权
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
#一般这句都不会执行成功
#不成功就执行
usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
有时候会不存在 my-default.cnf这个文件 可以直接新建一个
#修改启动脚本
vi /etc/init.d/mysqld
#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
#启动服务
service mysqld start
#测试连接
./mysql/bin/mysql -uroot
#加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql/bin
#刷新文件生效
source /etc/profile
#启动mysql
service mysqld start
#关闭mysql
service mysqld stop
#查看运行状态
service mysqld status
my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set=utf8
port = 3306
socket = /tmp/mysql.sock
[mysqld]
#skip-grant-tables
port = 3306
collation_server = utf8_general_ci
character_set_server = utf8
socket = /tmp/mysql.sock
basedir = /usr/local/mysql/
datadir =/usr/local/mysql/data/mysql
pid-file = /usr/local/mysql/data/mysql.pid
user = root
#不区分表名和列名的大小写
lower_case_table_names=1