首页 > 代码库 > linux安装mysql

linux安装mysql

1下载mysql

weget -P /home/qbt/mysql https://dev.mysql.com/get/archives/mysql-5.6/mysql-5.6.12-linux-glibc2.5-x86_64.tar.gz

2转到mysql路径

cd/ home/qbt/mysql 

3解压

tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz

4创建usr/local/mysql 路径

mkdir /usr/local/mysql

5移动解压后的目录至/usr/local/mysql

mv -rf  /home/qbt/mysql/mysql-5.6.33-linux-glibc2.5-x86_64/*  /usr/local/mysql

6添加用户组和用户

groupadd mysql

useradd -g mysql mysql

7安装

cd /usr/local/mysql;

mkdir ./data/mysql

chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
cp support-files/my-default.cnf /etc/my.cnf
#修改启动脚本
vi /etc/init.d/mysqld
 
#修改项:
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/mysql
 
#启动服务
service mysqld start
 
#测试连接
./mysql/bin/mysql -uroot
 
#加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了
export PATH=$PATH:/usr/local/mysql//bin<br>source /etc/profile
 
 
#启动mysql
service mysql start
#关闭mysql
service mysql stop
#查看运行状态
service mysql status
 

linux安装mysql