cd /usr/local/src
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
gmake
gmake install
cd ../
安装mysql
最新版软件通过源码安装
添加mysql组和mysql用户
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
usermod -s /bin/false mysql
将mysql和data文件安装到不同的物理磁盘上
建立连接
make && make install
cp ./support-files/my-huge.cnf /app/config/my.cnf
mkdir /db/mysql
chown mysql:mysql /app/server/mysql -R
chown mysql:mysql /db/mysql -R
find /var/lib/mysql/mysql -name '*.MYI'
netstat -antp
建立服务
cp ./support-files/mysql.server /etc/init.d/mysqld
chown mysql:mysql /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
将 mysql 加入开机启动
chmod +x /etc/init.d/mysqld
vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:)
chmod 777 /tmp
basedir=/app/server/mysql
datadir=/db/mysql/
mysqld_pid_file_path=/app/pid/mysql.pid
conf=/app/config/my.cnf
chkconfig --add mysqld
chkconfig --level 345 mysqld on
rm -rf /etc/my.cnf
一定要删除
/app/server/mysql/scripts/mysql_install_db --defaults-file=/app/config/my.cnf --basedir=/app/server/mysql --datadir=/db/mysql --user=mysql
/app/server/mysql/bin/mysqld_safe //第一次启动
修改密码
ps -ef |grep mysql
链接路径 不用 在/etc/profile 里加
ln -s /app/server/mysql/bin/mysql /usr/bin
ln -s /app/server/mysql/bin/mysqladmin /usr/bin
[root@localhost libexec]# mysqladmin -uroot password “youpassword”
#设置root帐户的密码
[root@localhost libexec]# mysql -uroot -p
# 输入你设置的密码
mysql>use mysql;
mysql>delete from user where password=”";
#删除用于本机匿名连接的空密码帐号
mysql>flush privileges;
delete from user where host !='localhost';
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./bootstrap
gmake
gmake install
cd ../
安装mysql
最新版软件通过源码安装
添加mysql组和mysql用户
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
usermod -s /bin/false mysql
将mysql和data文件安装到不同的物理磁盘上
在mysql 源码目录下执行:
cmake -DCMAKE_INSTALL_PREFIX=/app/server/mysql -DMYSQL_DATADIR=/db/mysql/ -DMYSQL_UNIX_ADDR=/app/pid/mysql.sock -DMYSQL_TCP_PORT=33306 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_EMBEDDED_SERVER=0 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DWITH_DEBUG=0 -DWITH_SSL=yes建立连接
make && make install
cp ./support-files/my-huge.cnf /app/config/my.cnf
mkdir /db/mysql
chown mysql:mysql /app/server/mysql -R
chown mysql:mysql /db/mysql -R
find /var/lib/mysql/mysql -name '*.MYI'
netstat -antp
建立服务
cp ./support-files/mysql.server /etc/init.d/mysqld
chown mysql:mysql /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
将 mysql 加入开机启动
chmod +x /etc/init.d/mysqld
vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:)
chmod 777 /tmp
basedir=/app/server/mysql
datadir=/db/mysql/
mysqld_pid_file_path=/app/pid/mysql.pid
conf=/app/config/my.cnf
chkconfig --add mysqld
chkconfig --level 345 mysqld on
rm -rf /etc/my.cnf
一定要删除
/app/server/mysql/scripts/mysql_install_db --defaults-file=/app/config/my.cnf --basedir=/app/server/mysql --datadir=/db/mysql --user=mysql
/app/server/mysql/bin/mysqld_safe //第一次启动
修改密码
ps -ef |grep mysql
链接路径 不用 在/etc/profile 里加
ln -s /app/server/mysql/bin/mysql /usr/bin
ln -s /app/server/mysql/bin/mysqladmin /usr/bin
[root@localhost libexec]# mysqladmin -uroot password “youpassword”
#设置root帐户的密码
[root@localhost libexec]# mysql -uroot -p
# 输入你设置的密码
mysql>use mysql;
mysql>delete from user where password=”";
#删除用于本机匿名连接的空密码帐号
mysql>flush privileges;
delete from user where host !='localhost';
建立专用账户
如果需要设置数据库外网访问:
1.在mysql中执行
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
flush privileges;
2.别忘了看看路由表
vi /etc/sysconfig/iptables
看看3306(上文中我用的33306端口)端口是否在其中,如果没有,在最后一行之前加上
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
然后重启iptables:
service iptables restart