centos二进制安装MySQL-5.7数据库

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz /usr/local/

cd /usr/local/

tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql

cd mysql

cd support-files/

cp my-default.cnf /etc/my.cnf

vi /etc/my.cnf

输入
[mysql]
default-character-set=utf8

[mysqld]
default-storage-engine=INNODB
character_set_server=utf8

拷贝mysql启动文件
cp mysql.server /etc/init.d/mysql

vi /etc/init.d/mysql

在对应位置添加
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

创建和mysql相关的用户和用户组

groupadd mysql
useradd -r -g mysql mysql
passwd mysql
chown -R mysql:mysql /usr/local/mysql/

usermod -d /home/mysql mysql

初始化数据库
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

根据初始日志记录,得到root@localhost的初始密码oEo&PI>hL46n

启动数据库

./mysqld_safe --user=mysql &


登录后修改root密码

./mysql -uroot -p
然后设置密码为chenli
set password=password('chenli');

grant all privileges on *.* to root@'%' identified by 'chenli';
grant all privileges on *.* to root@'192.168.1.98' identified by 'chenli';

flush privileges;

设置开机启动
chkconfig --add mysql
chkconfig mysql on


GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'chenli' WITH GRANT OPTION;

GRANT ALL ON *.* TO 'root'@'%';
GRANT ALL ON *.* TO 'root'@'localhost';
GRANT ALL ON *.* TO 'root'@'127.0.0.1';

CREATE USER 'sa'@'%' IDENTIFIED BY 'chenli';
CREATE USER 'sa'@'localhost' IDENTIFIED BY 'chenli';
CREATE USER 'sa'@'127.0.0.1' IDENTIFIED BY 'chenli';

GRANT ALL ON *.* TO 'sa'@'%';

GRANT ALL ON *.* TO 'sa'@'localhost';
GRANT ALL ON *.* TO 'sa'@'127.0.0.1';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值