Mysql安装
[root@web01 ~]# useradd -s /sbin/noligin mysql -M
[root@web01 tools]# mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49
[root@web01 tools]# cd /application/mysql-5.5.49/
[root@web01 tools]# ln -s /application/mysql-5.5.49/ /application/mysql
[root@web01 mysql]# chown -R mysql.mysql /application/mysql/
[root@web01 mysql]# ./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql ?初始化
修改配置文件
cd /application/mysql/bin
sed -i ‘s#/usr/local/#/application/#g‘ mysqld_safe
sed -i ‘s#/usr/local/#/application/#g‘ support-files/mysql.server
cp support-files/mysql.server /etc/init.d/mysqld 拷贝到启动脚本
chmod +x /etc/init.d/mysqld 赋予权限
[root@web01 bin]# less mysqld_safe
指定配置文件
[root@web01 mysql]# cp support-files/my-small.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@web01 mysql]# /application/mysql/bin/mysqld_safe --user=mysql &
[1] 6953
180411 21:35:31 mysqld_safe Logging to ‘/application/mysql/data/web01.err‘.
180411 21:35:31 mysqld_safe Starting mysqld daemon with databases from /application/mysql/data
PATH="/application/mysql/bin:$PATH" 设置环境变量
echo "PATH="/application/mysql/bin:$PATH"" >>/etc/profile
. /etc/profile
[root@web01 mysql]# lsof -i :3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 7183 mysql 10u IPv4 61272 0t0 TCP *:mysql (LISTEN)
启动关闭测试
[root@web01 mysql]# /etc/init.d/mysqld stop
Shutting down MySQL.180411 21:44:45 mysqld_safe mysqld from pid file /application/mysql/data/web01.pid ended
SUCCESS!
[1]+ Done /application/mysql/bin/mysqld_safe --user=mysql
[root@web01 mysql]# lsof -i :3306
[root@web01 mysql]# /etc/init.d/mysqld start
Starting MySQL... SUCCESS!
Mysql数据库安装总结-脚化
useradd -s /sbin/noligin mysql -M
mkdir –p /application/
mkdir -p /home/oldboy/tools
cd /home/oldboy/tools/
tar zxf mysql-5.5.49-linux2.6-x86_64.tar.gz
useradd -s /sbin/noligin mysql -M
mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49
cd /application/mysql-5.5.49/
ln -s /application/mysql-5.5.49/ /application/mysql
chown -R mysql.mysql /application/mysql/
./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
cd /application/mysql/bin
sed -i ‘s#/usr/local/#/application/#g‘ mysqld_safe
cd ..
sed -i ‘s#/usr/local/#/application/#g‘ support-files/mysql.server
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
\cp support-files/my-small.cnf /etc/my.cnf
/application/mysql/bin/mysqld_safe --user=mysql &
PATH="/application/mysql/bin:$PATH"
echo "PATH="/application/mysql/bin:$PATH"" >>/etc/profile
. /etc/profile
lsof -i :3306
/etc/init.d/mysqld stop
chkconfig mysqld on
原文地址:http://blog.51cto.com/jungiewolf/2108535