Oracle Linux 6.8安装 mysql 5.7.17的详细教程
安装MySQL 5.7.17的方法如下所示:
1.下载
http://www.codeyyy.com/linux/149-150-153.html
2.上传解压
tar -xvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
3.新建mysql目录
mkdir -p /usr/local/mysql/data
mv mysql-5.7.17-linux-glibc2.5-x86_64/* /usr/local/mysql/
4.添加用户组
groupadd mysql
5.新建用户
useradd -g mysql -d /usr/local/mysql mysql
6.改变mysql目录权限
chown -R mysql.mysql /usr/local/mysql/
7.初始化数据库(在MySQL目录下安装)
因为这里是5.7版本的所以不适用了(./bin/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data/)
./bin/mysqld –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data –initialize
牢记上面的随机密码
root@localhost: >HLaOQH;U6L3
8.复制配置文件到 /etc/my.cnf 这里是mysql的基本配置问题
cp -a ./support-files/my-default.cnf /etc/my.cnf #会有一个选择是否覆盖原有文件,直接按 y回车选择是就可以
并编辑 vi my.cnf
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /usr/localmysql/data
port = 3306
# server_id = …..
socket = /tmp/mysql.sock
character-set-server=utf-8
这个时候复制了my.cnf 再去启动会启动失败(这个文件不作复制)
mysql/support-files/mysql.server restart
9.把mysql放到本地系统服务中
cp -a ./support-files/mysql.server /etc/init.d/mysqld
10.配置mysql
# cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld # 拷贝启动文件到/etc/init.d/下并重命令为mysqld
# chmod 755 /etc/init.d/mysqld # 增加执行权限
# chkconfig –list mysqld # 检查自启动项列表中没有mysqld这个,
# chkconfig –add mysqld # 如果没有就添加mysqld:
# chkconfig mysqld on # 用这个命令设置开机启动:
11.创建软链接
# ln -s /home/mysql/bin/mysql /usr/bin/mysql
12.mysql服务的启动/重启/停止
# service mysqld start # 启动服务
# service mysqld restart # 重启服务
# service mysqld stop # 停止服务
13.进入mysql
./bin/mysqladmin -u root -p 或者 mysql -u root -p
输入开始保存的临时密码
>HLaOQH;U6L3
14.修改密码
1).在mysql 中修改密码
mysql> SET PASSWORD = PASSWORD(‘123456’);
2)可以通过临时文件中找到之前的密码(没试过)
find / -name mysql.sock
15.设置编码
show variables like ‘character%’; # 查询编码
SET character_set_database = utf8; —-设置编码
16.mysql远程授权2种(重点)
1)mysql> grant all privileges on *.* to ‘root’@’%’ identified by ‘123456’;
2)grant all on *.* to ‘root’@’%’ identified by ‘123456’;
以上所述是小编给大家介绍的Oracle Linux 6.8安装 mysql 5.7.17的详细教程,大家如有疑问可以留言,或者联系站长。感谢亲们支持!!!