采用源码安装,可以根据实际生产环境加入一些参数,提升mysql性能
mysql官网https://www.mysql.com/
本文采用5.1版本尽心安装说明,后面版本如5.5安装方法会有些不一样,在公司的一些生产环境中也有用到
5.1版本mysql。
下载mysql源码
解压tar zxf mysql-5.1.72.tar.gz
cd ?mysql-5.1.72
配置
./configure --prefix=/usr/local/mysql \
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock \
--localstatedir=/usr/local/mysql/data\ ? ?
--enable-assemble \
--enable-thread-safe-client \
--with-mysqld-user=mysql \
--with-big-tables \
--with-pthread \
--with-extra-charsets=complex \
--with-readline \
--with-ssl \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static
[[email protected] mysql-5.1.72]# ./configure --help ?查看具体的配置参数
make&&make install
这里采用开发测试模板
/bin/cp support-files/my-small.cnf ? /etc/my.cnf
创建数据库文件
mkdir -p /usr/local/mysql/data
chown -R mysql /usr/local/mysql授权mysql用户可以访问mysql目录
/usr/local/mysql/bin/mysql_install_db --user=mysql安装mysql数据库文件
安装完后会有一些相关说明,如如何启动等等。
安装安装说明方法启动mysql
/usr/local/mysql/bin/mysqld_safe/usr/local/mysql/bin/mysqld_safe & ? ?&表示后台运行
为了更方便的启动mysql,可以将mysql加到全局变量中
将mysql加到全局变量中echo ‘export PATH=$PATH:/usr/local/mysql/bin‘>>/etc/profile
source /etc/profile
执行mysql进入数据库
[[email protected] mysql-5.1.72]# mysql
Welcome to the MySQL monitor. ?Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.72 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
配置/etc/init.d/mysqld启动mysql
cp support-files/mysql.server ?/etc/init.d/mysqld
chmod 700 /etc/init.d/mysqld 授权,
将mysql服务加到开机启动?
[[email protected] mysql-5.1.72]# chkconfig --add mysqld
[[email protected] mysql-5.1.72]# chkconfig mysqld ?on
mysql进入数据库
设置密码set password for [email protected]=PASSWORD(‘123456‘);
后续采用mysql -uroot -p形式进入mysql数据库