添加用户及分组
groupadd mysql
useradd -g mysql mysql
解压安装包,文件放在 /usr/local/mysql
在/usr/local/mysql目录下创建 data目录
更改/usr/local/mysql目录 所属用户组用户及权限
编译安装及初始化mysql
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
初始化后,记下输出日志中的初始密码
编辑配置文件 /etc/my.cnf
datadir=/usr/local/mysql/data
port=3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
#max_connections=600
innodb_file_per_table=1
socket=/tmp/mysql.sock
log-error=/var/mysql/data/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
配置环境变量 /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
启动
/usr/local/mysql/support-files/mysql.server start
进入mysql
mysql -u root -p pw
自动进入重置密码步骤
设置开机自动启动
复制服务文件到init.d下,并命名为mysqld
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mtsqld
添加可执行权限
chmod +x /etc/init.d/mysqld
添加服务
chkconfig --add mysqld
查看服务
chkconfig --list
无法启动的问题
因为 /etc/my.cnf 中配置的 error-log 地址 没有写入权限
网友评论