MYSQL安装步骤:
#下载,解压源码包,移动到指定目录:
wget http://syslab.comsenz.com/downloads/linux/mysql-5.1.40-linux-x86_64-icc-glibc23.tar.gz
tar zxvf mysql-5.1.40-linux-x86_64-icc-glibc23.tar.gz
mv mysql-5.1.40-linux-x86_64-icc-glibc23.tar.gz /usr/local/mysql
#新建数据库存储路径:
mkdir -p /data/mysql
#创建mysql的管理用户:
useradd -s /sbin/nologin mysql
chown -R /usr/local/mysql
#拷贝mysql实例和到开机启动服务
cp /usr/local/mysql/data/support-files/my-medium.cnf /etc/my.cnf
cp /usr/local/mysql/data/support-files/mysql.server /etc/init.d/mysqld
#修改上述两个配置文件
vi /etc/my.cnf
log-bin=mysql-bin/server-id =1/binlog_format=mixed三个注释掉,后面mysql主从时候用到
#socket,使用socket通信,关掉
后面添加一行skip-network关闭3306端口,外网检测不到
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/myslq/data/mysql
#将mysqld添加到chkconfig服务启动项
chkconfig --add mysqld
chkconfig mysqld on(chkconfig查看已添加哪些启动服务;chkconfig --del xx删除)
#启动mysqld服务
service mysqld start或者/etc/init.c/mysqld start
#检验是否成功:
ps aux |grep mysql或者netstat -npl |grep 3306
报错:
# ./script/mysql_install_db --user=mysql --datadir=/data/mysql 在对mysql初始化时候报错
FATAL ERROR: Could not find ./bin/my_print_defaults
解决方法:首先没有指定datadir的绝对路径,再没有指定basedir路径
./script/mysql_install_db --user=mysql --datadir=/usr/local/data/mysql --basedir=/usr/local/mysql
echo $?查看输出是否正确:0正确,1有错误
# ./script/mysql_install_db --user=mysql --datadir=/usr/local/data/mysql --basedir=/usr/local/mysql初始化时报错:
ERROR: 1 Can't create/write to file '/usr/local/mysql/data/mysql/mysql/db.MYI' (Errcode: 13)
解决方法:还是/usr/local/mysql的权限问题
chown -R mysql:mysql /usr/local/mysql
echo $? 0和两个OK
#/etc/init.d/mysqld start启动mysqld服务时
报错:Starting MySQL.. ERROR! Manager of pid-file quit without updating file.
解决方法:重新初始化 ./script/mysql_install_db --user=mysql
结果:SUCCESS