MySQl 5.7 初始化方式变更

Window 64:

1.修改my-default.ini名称 ==> my.ini

 

[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin=mysql-bin
# These are commonly set, remove the # and set as required.
basedir = D:/MySQL/mysql-5.7.12-winx64
datadir = D:/MySQL/mysql-5.7.12-winx64/data
port = 3306
server_id = 10

 2.初始化数据文件

 

 

mysqld --defaults-file=../my.ini --initialize --console

 –initialize 初始化数据文件,设置root账号密码为随机密码,注意查看输出日志

 

 

3.安装/删除mysql服务

 

mysqld  install mysql57
sc delete mysql57

 4.启动/停止mysql

 

 

net start mysql57
net stop mysql57

 5.连接mysql ,修改root密码

 

 

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

 

 

 

Centos :

1.创建mysql 用户

 

groupadd mysql 
useradd -r -g mysql mysql

 2.初始化数据文件

 

 

mysqld --initialize --user=mysql --datadir=./data --basedir=.

 若找不到mysqld命令,配置环境变量

 

 

MYSQL_HOME=/opt/mysql-5.7.12
PATH=$MYSQL_HOME/bin:$PATH
export PATH

 3.将mysql/support-files下的my-default.cnf改名为my.cnf,拷贝到/etc目录下

 

 

[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin=mysql-bin
# These are commonly set, remove the # and set as required.
basedir = /opt/mysql/mysql-5.7.12
datadir = /opt/mysql/mysql-5.7.12/data
port = 3306
server_id = 10
socket = /opt/mysql/mysql-5.7.12/tmp/mysql.sock
[client]
socket =  /opt/mysql/mysql-5.7.12/tmp/mysql.sock

 

 

4.设置mysql以服务运行并且开机启动 
将MYSQL_HOME/ support-files/mysql.server 拷贝为/etc/init.d/mysql并设置运行权限

 

cp mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql

 把mysql注册为开机启动的服务

 

 

chkconfig --add mysql

 5.启动/停止mysql

 

/etc/init.d/mysql start
/etc/init.d/mysql stop

 6.连接mysql ,修改root密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

 

 

闲适悦www.xianshiyue.com    共建电影分享平台

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值