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
1
[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
1
mysqld--defaults-file=../my.ini--initialize--console
–initialize 初始化数据文件,设置root账号密码为随机密码,注意查看输出日志
3.安装/删除mysql服务
mysqld install mysql57 sc delete mysql57
1
mysqldinstallmysql57scdeletemysql57
4.启动/停止mysql
net start mysql57 net stop mysql57
1
netstartmysql57netstopmysql57
5.连接mysql ,修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
1
ALTERUSER'root'@'localhost'IDENTIFIEDBY'new_password';
Centos :
1.创建mysql 用户
groupadd mysql useradd -r -g mysql mysql
1
groupaddmysqluseradd-r-gmysqlmysql
2.初始化数据文件
mysqld --initialize --user=mysql --datadir=./data --basedir=.
1
mysqld--initialize--user=mysql--datadir=./data--basedir=.
若找不到mysqld命令,配置环境变量
MYSQL_HOME=/opt/mysql-5.7.12 PATH=$MYSQL_HOME/bin:$PATH export PATH
1
MYSQL_HOME=/opt/mysql-5.7.12PATH=$MYSQL_HOME/bin:$PATHexportPATH
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
1
[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
1
cpmysql.server/etc/init.d/mysqlchmod+x/etc/init.d/mysql
把mysql注册为开机启动的服务
chkconfig --add mysql
1
chkconfig--addmysql
5.启动/停止mysql
/etc/init.d/mysql start /etc/init.d/mysql stop
1
/etc/init.d/mysqlstart/etc/init.d/mysqlstop
6.连接mysql ,修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
1
ALTERUSER'root'@'localhost'IDENTIFIEDBY'new_password';
闲适悦:www.xianshiyue.com 共建电影分享平台