mysql----二进制包安装

时间:2024-01-18 14:10:02

1、增加mysql用户

useradd mysql

2、解压mysql 二进制包到/usr/local/

tar -xzvf mysql-5.6.-linux-glibc2.-x86_64.tar.gz -C/usr/local/

3、创建连接

cd /usr/local/
ln -s mysql-5.6.-linux-glibc2.-x86_64 mysql

4、初始化数据库

cd /usr/local/mysql/
./scripts/mysql_install_db --user=mysql datadir=/usr/local/mysql/data --basedir=/usr/local/mysql/

5、配置启动脚本

cd /usr/local/mysql/
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig mysqld on

6、编辑配置文件/etc/my.cnf

[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

7、到这里就可以启动mysql数据库了

service mysqld start

8、以下的配置也许你不会用到

8.1、增加man文档,在/etc/man.config 文件中加一行

MANPATH /usr/local/mysql/man

8.2、增加库文件查找路径

cd /etc/ld.so.conf.d
touch mysql.conf
echo "/usr/local/mysql/lib" >mysql.conf

8.3、增加头文件查找路径

mkdir /usr/include/mysql
cp /usr/local/mysql/include/* /usr/include/mysql

9、为了方便使用可以把PATH路径改下、在/etc/profile 的最后加一行

echo 'export PATH=/usr/local/mysql/bin/:${PATH}'>>/etc/profile
source /etc/profile