初始化方式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.初始化數(shù)據(jù)文件
mysqld --defaults-file=../my.ini --initialize --console
–initialize 初始化數(shù)據(jù)文件快鱼,設置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.創(chuàng)建mysql 用戶
groupadd mysql
useradd -r -g mysql mysql
2.初始化數(shù)據(jù)文件
mysqld --initialize --user=mysql --datadir=./data --basedir=.
若找不到mysqld命令妨蛹,配置環(huán)境變量
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