首页 > 数据库技术 > 详细

MySQl 5.7 初始化方式变更

时间:2016-07-07 02:17:12      阅读:707      评论:0      收藏:0      [点我收藏+]

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? ? 共建电影分享平台

?

?

?

?

MySQl 5.7 初始化方式变更

原文:http://silentwu.iteye.com/blog/2308722

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!