linux下安装mysql
linux下安装mysql
1.删除已安装的mysql
(1) 查看是否已安装mysql rpm -qa|grep mysql
(2) 卸载mysql
yum remove mysql mysql-server mysql-libs mysql-common
rm -rf /var/lib/mysql
rm -rf /etc/my.cnf
- 安装mysql
(1)官网下载 mysql-5.6.38-linux-glibc2.12-i686.tar.gz 压缩包
解压压缩包到指定目录
tar -zxvf mysql-5.6.38-linux-glibc2.12-i686.tar.gz
cp -r mysql-5.6.38-linux-glibc2.12-i686 /usr/local/mysql
建立软连接 : ln -s /usr/local/database/mysql mysql
(2)创建mysql 与用户组,-s /bin/false 表示该用户不能登录
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
(3)为 mysql 用户添加权限
chown -R mysql ./
chgrp -R mysql ./
(4)创建data目录并添加权限
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
(5)拷贝配置文件并修改配置文件
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
修改配置[mysqld]
basedir=/usr/localhost/database/mysql
datadir=/data/mysql
character-set-server=utf8
(6)初始化数据库
./scripts/mysql_install_db –user=mysql –basedir=/usr/local/database/mysql/ –datadir=/data/mysql
(7) 添加环境变量
vi /etc/profile
PATH=/home/cbt/svr/mysql/bin:$PATH
export PATH
source /etc/profile
(8)启动数据库
service mysqld start
关闭数据库
service mysqld stop
查看运行状态
service mysqld status
(9)其他配置
开机启动
chkconfig mysqld on