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';

参考
https://blog.csdn.net/u010898329/article/details/83064373

你可能感兴趣的:(MySQl 5.7 安装)