cat >/etc/my.cnf <<EOF[mysqld]
basedir =/usr/local/mysql
datadir =/opt/data
socket =/tmp/mysql.sock
port =3306
pid-file =/opt/data/mysql.pid
user = mysql
skip-name-resolve
EOF
9、配置服务启动脚本
cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g'/etc/init.d/mysqld
sed -ri 's#^(datadir=).*#\1/opt/data#g'/etc/init.d/mysqld
10、启动mysql,并修改密码
chkconfig mysqld on #设置为开机自动启动
service mysqld start
ss -antl |grep 3306
11、登录MySQL设置密码
mysql -uroot
SETPASSWORDFOR'root'@'localhost'='yeshengdjlanyangyang';
flush privileges;