linux下mysql 5.5的安装方法:
1、安装所需要系统库相关库文件
gcc等开发包,在安装linux系统的时候安装。
2、创建mysql安装目录
# mkdir -p /usr/local/mysql/
3、创建数据存放目录
# mkdir -p /service/data/
4、创建用户和用户组与赋予数据存放目录权限
# groupadd mysql
# useradd -g mysql mysql
# chown mysql:mysql -R /service/data/
5、安装cmake(mysql5.5以后是通过cmake来编译的 )
# wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
# tar zxvf cmake-2.8.4.tar.gz
# cd cmake-2.8.4
#./configure
# make && make install
最省事的方法就是用yum install cmake 来安装,但前提是得配置yum源,也可以从系统安装盘中寻找cmake 的rpm包。
6、下载解压mysql 5.5.15
wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.15.tar.gz
[[email protected] down]# tar zxvf mysql-5.5.15.tar.gz
[[email protected] down]# cd mysql-5.5.15
7、编辑mysql编译参数
cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/service/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DSYSCONFDIR=/etc \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0 \
-DENABLED_LOCAL_INFILE=1
源代码配置选项说明:
/***************编译参数注释*************************************************
//mysql安装的主目录,5.5.8版本默认为/usr/local/mysql,所以可以不添加
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
//mysql数据保存的路径,自定义
-DMYSQL_DATADIR=/home/system_username/mysql/mysqldata
//mysql配置文件地址------The default my.cnf option file directory
-DSYSCONFDIR=/etc
//Compile storage engine xxx statically into server
/*Storage engines are built as plugins. You can build a plugin as a static module (compiled into the server)
*or a dynamic module (built as a dynamic library that must be installed into the server using the INSTALL
*PLUGIN statement or the --plugin-load option before it can be used). Some plugins might not support static
*or dynamic building.
*/
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_FEDERATED_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
//Unix socket file
/**The Unix socket file path on which the server listens for socket
connections. This must be an absolute path *name. The default is
/tmp/mysql.sock
*/
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock
//数据库服务器TCP/IP连接的监听端口,默认为3306
-DMYSQL_TCP_PORT=3306
//Whether to enable LOCAL capability in the client library for LOAD DATA INFILE
//默认为关闭,这里开启
-DENABLED_LOCAL_INFILE=1
/数据库编码设置
-DWITH_EXTRA_CHARSETS=all
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
*****************************************end***************************/
8、make && make install
9、初始化数据库并修改默认密码
cp support-files/my-huge.cnf /etc/my.cnf
内存在1G-2G选择my-huge.cnf较好些。
vi /etc/my.cnf
可以根据需要在[mysqld]下面增加上:
interactive_timeout = 100 wait_timeout = 100 #上面两个参数同时设置才会生效 max_connections = 1500 max_connect_errors = 1500 default-storage-engine = MyISAM
创建启动脚本:
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
初始化mysql并生成授权库:
bash scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/service/data/
启动mysql:
/etc/init.d/mysqld start
登录mysql:
/usr/local/mysql/bin/mysql -u root -p
修改密码:
mysql>use mysql ;
mysql>update user set password=PASSWORD("12345") where user=‘root‘;
mysql>FLUSH PRIVILEGES;
也可将MYSQL加入启动项,设置成服务启动:
chkconfig --add mysqld
chkconfig --level 345 mysqld on
service mysqld restart
注意:
mysql 5.5 以后的tar包是用cmake来进行安装的,而不是之前的Autotools方式即(configure方式)
相关日志:
linux下搭建nginx+php(FastCGI)+mysql运行环境
rpm删除安装包时总是提示specifies multiple packages
在Linux系统下安装大于mysql5.5版本的数据库,布布扣,bubuko.com