全部博文(921)
分类: LINUX
2014-01-13 15:16:33
1、安装 编译器。
1)、下载cmake
#cd /usr/local/src
#wget
2)、解压cmake
#tar -zvxf cmake-2.8.3.tar.gz
3)、配置编译
#cd cmake-2.8.3
#yum -y install gcc
#yum -y install gcc-c++
#./configure
#make
#make install
-------------------------------------------------------
安装ncurses-devel: yum –y install ncurses-devel
2、安装MySQL
1)、下载MySQL。
#cd /usr/local/src
#wget
打不开可以直接到下载到本地,再上传
2)、添加必要的组和拥有者
#groupadd mysql
#useradd -r -g mysql mysql
3)、解压MySQL
#tar -zvxf mysql-5.5.28.tar.gz
4)、配置编译
#mkdir /usr/local/mysql
#mkdir /usr/local/mysql/data
#cd /usr/local/src/mysql-5.5.28
#cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFIGDIR=/usr/local/mysql/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
#make
#make install
注意事项:
重新编译时,需要清除旧的对象文件和缓存信息。
# make clean
# rm -f CMakeCache.txt
5)、设置目录权限
# cd /usr/local/mysql
# chown -R root:mysql . //空格之后小数点不要忘了 ,把当前目录中所有文件的所有者所有者设为root,所属组为mysql
# chown -R mysql:mysql data
6)、配置文件
# cp support-files/my-medium.cnf /etc/my.cnf //这个配置仅适合小内存系统(32M - 64M)
打开如下注释:
innodb_data_home_dir = /usr/local/mysql/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /usr/local/mysql/data
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
添加默认字符集:
[mysqld]
max_connections = 10000 //根据服务器性能调节
basedir = /usr/local/mysql //设置安装目录,这样在系统启动时才能正确运行到/etc/rc.d/init.d/mysql start
7)、创建系统数据库的表
# cd /usr/local/mysql
# scripts/mysql_install_db --user=mysql
8)、设置权限启动
设置环境变量:
# vi /root/.bash_profile
在PATH=$PATH:$HOME/bin添加参数为:
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib
#source /root/.bash_profile
手动启动MySQL:
# cd /usr/local/mysql
# ./bin/mysqld_safe --user=mysql & //启动MySQL,但不能停止
启动日志写在此文件下:/usr/local/mysql/data/localhost.err
关闭MySQL服务
# mysqladmin -u root -p shutdown //这里MySQL的root用户还没有配置密码,所以为空值。
通过脚本启动MySQL:
# ln -s /usr/local/mysql/support-files/mysql.server /usr/local/mysql
//必须注意,是放在mysql目录下,不是bin目录下
# cp /usr/local/mysql/support-files/mysql.server /usr/local/mysql
# mysql.server start //启动mysql
# mysql.server stop //停止mysql
在引导时启动MySQL :
# ln -s /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql
# ln -s /usr/local/mysql/mysql.server /etc/rc.d/init.d/mysql
# cd /etc/rc.d/init.d
# chkconfig --add mysql //配置是否自动启动, chkconfig --del mysql 可删除
# chmod +x /etc/rc.d/init.d/mysql //添加如执行权限
9)、修改MySQL的root用户的密码:
# mysql -u root mysql
mysql>use mysql;
mysql>desc user;
mysql>update user set Password = password('xxxxxx') where User='root';
mysql>select Host,User,Password from user where User='root';
mysql>flush privileges;
mysql>exit
重新登录:mysql -u root -p
修改MySQL的root用户的密码以及打开远程连接
[root@localhost mysql]# mysql -u root mysql
mysql> use mysql;
mysql> desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //为root添加远程连接的能力
mysql> update user set Password = password('123456') where User='root'; //设置root用户密码
mysql> select Host,User,Password from user where User='root';
mysql> flush privileges;
mysql> exit
原文链接: