MySQl 5.7 initialization method changes

Window 64:

1. Modify my-default.ini name ==> 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. Initialize the data file

 

 

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

 --initialize Initialize the data file, set the root account password to a random password, pay attention to check the output log

 

 

3. Install/remove mysql service

 

mysqld  install mysql57
sc delete mysql57

 4. Start/stop mysql

 

 

net start mysql57
net stop mysql57

 5. Connect to mysql and modify the root password

 

 

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

 

 

 

cents :

1. Create a mysql user

 

groupadd mysql
useradd -r -g mysql mysql

 2. Initialize the data file

 

 

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

 If the mysqld command is not found, configure the environment variable

 

 

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

 3. Rename my-default.cnf under mysql/support-files to my.cnf and copy it to the /etc directory

 

 

[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. Set mysql to run as a service and start it up 
Copy MYSQL_HOME/support-files/mysql.server to /etc/init.d/mysql and set the running permission

 

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

 Register mysql as a startup service

 

 

chkconfig --add mysql

 5. Start/stop mysql

 

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

 6. Connect to mysql and modify the root password

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

 

 

Xianshiyue : www.xianshiyue.com     to build a movie sharing platform

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326764243&siteId=291194637
Recommended