修改配置文件
vi ~/.my.cnf
# 在~/.my.cnf文件中添加下列信息
[client]
port = 3306
socket = /home/ocetl/mysql-5.7.18/mysql.sock
[mysqld]
user = ocetl
basedir = /home/ocetl/mysql-5.7.18
datadir = /home/ocetl/mysql-5.7.18/data
port = 3306
server-id = 1
socket = /home/ocetl/mysql-5.7.18/mysql.sock
character-set-server = utf8
log-error = /home/ocetl/mysql-5.7.18/logs/error.log
pid-file = /home/ocetl/mysql-5.7.18/logs/mysql.pid
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
修改环境变量
export MY_BASEDIR_VERSION=~/mysql-5.7.18/
export PATH=${MY_BASEDIR_VERSION}/bin:$PATH
创建目录
mkdir -p ~/mysql-5.7.18/data
mkdir -p ~/mysql-5.7.18/logs
初始化
mysqld --initialize --user=ocetl
启动与停止
# 启动
mysqld &
# 停止
mysqladmin -uhive -phive shutdown
修改初始密码
# root初始密码获取
grep "password" ~/mysql-5.7.18/logs/error.log
# 使用上述密码登录
mysql -uroot -p
alter user root@localhost identified by 'Asia2017_';
flush privileges;