添加mysql帐号
groupadd mysql
useradd -r -g mysql mysql
编译必需先安装
cmake-2.8.4 和 bison-2.4.3
安装成功后解压mysql-5.5.15.tar.gz:
在源码根目录打开终端输入以下配置参数并回车
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MEMORY_STORAGE_ENGINE=1
-DWITH_READLINE=1
-DENABLED_LOCAL_INFILE=1
-DMYSQL_DATADIR=/var/mysql/data
-DMYSQL_USER=mysql
成功执行以下命令后在最后会见到 (/root/Desktop/是你的源码目录,视你的情况定)
-- Build files have been written to: /root/Desktop/mysql-5.5.15
运行make安装:
make
make install
以下步骤就不一一解说了:
cd /mysql/mysql
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp ./support-files/my-small.cnf ./my.cnf
cp support-files/mysql.server mysql; chmod +x mysql
chown -R mysql:root .
./mysql start
./bin/mysqladmin -u root -p 123456
添加开机启动服务
chkconfig --add mysql
chkconfig mysql on
service mysql start
问题描述:
[root@bogon mysql-5.1.41]# /etc/rc.d/init.d/mysqld startStarting MySQL.Manager of pid-file quit without updating file.[失败]
解决办法:
配置的时候有一个步骤是 cp support-files/my-medium.cnf /etc/my.cnf ; 就编辑my.cnf,在[mysqld]下面加上:datadir = /usr/local/mysql/data
例如# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_s ...
2.首先到/usr/local/mysql/data先 chown -R mysql:mysql * 然后杀掉mysql进程,在启动musql就行了
打开/etc/selinux/config,把SELINUX=enforcing改为SELINUX=disabled后存盘退出重启机器试试3.
4.确实一般都是my.cnf配置文件的问题
/etc/my.cnf来自以下文件:
如果你的内存≤64M,则复制/usr/local/share/mysql/my-small.cnf为/etc/my.cnf
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld daemon
# doesn't use much resources.
如果内存是128M,则复制/usr/local/share/mysql/my-medium.cnf为/etc/my.cnf
# This is for a system with little memory (32M - 64M) where MySQL plays
# an important part, or systems up to 128M where MySQL is used together with
# other programs (such as a web server)
如果内存是512M,则复制/usr/local/share/mysql/my-large.cnf为/etc/my.cnf
# This is for a large system with memory = 512M where the system runs mainly
# MySQL.
如果内存是1-2G,则复制/usr/local/share/mysql/my-huge.cnf为/etc/my.cnf
# This is for a large system with memory of 1G-2G where the system runs mainly
# MySQL.