参考:专注、坚持的博客,网址:https://www.cnblogs.com/xiaotao726/p/6562265.html
1 下载mysql压缩包
wget http://dev.MySQL.com/get/Downloads/MySQL-5.7/mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz2 解压
tar -xzvf mysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz
3 生成data文件
4 创建mysql用户组以及用户
groupadd mysql
useradd -r -g mysql mysql
5 初始化
./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
6复制配置文件到/etc/my.cnf
cp -a ./support-files/my-default.cnf /etc/my.cnf (选择y)
7 MySQL的服务脚本放到系统服务中
cp -a ./support-files/mysql.server /etc/init.d/mysqld 修改my.cnf文件 # These are commonly set, remove the # and set as required. basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 # server_id = ..... socket = /tmp/mysql.sock character-set-server = utf8 # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M
8 创建ln
ln -s /usr/local/mysql/ /usr/bin/
9 启动服务
opt/tc/mysql/mysql5.7/support-files# ./mysql.server start
service mysqld start10 初始化密码
[root@localhost ~]# cat /root/.mysql_secret # Password set for user 'root@localhost' at 2017-03-16 00:52:34 ws;fmT7yh0CM
11 赋予权限
chown -R mysql /opt/tc/mysql/mysql-5.7.11-linux-glibc2.5-x86_64
chown -R mysql /opt/tc/mysql/mysql-5.7.11-linux-glibc2.5-x86_64/data
12 切换到mysql用户启动服务器
su mysql
进入bin中
./mysql -u root -p
alter user root@localhost identified by 'tiger'; flush privileges;
show databases;