cmake 安装mysql 5.5
##############
1、 首先安装cmake软件
cd /home/lvnian/tools/
tar xf cmake-2.8.8.tar.gz
cd cmake-2.8.8
./configure
#CMake has bootstrapped. Now run gmake.
gmake
gmake install
cd ../
########################
2、安装依赖包
yum install ncurses-devel -y
########################
3、创建用户和组
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
########################
4、cmake安装mysql
cd /home/lvnian/tools/
tar zxf mysql-5.5.32.tar.gz
cd mysql-5.5.32
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
make && make install
#-- Build files have been written to: /home/oldboy/tools/mysql-5.5.32
提示,编译时可配置的选项很多,具体可参考结尾附录或官方文档:
make
#[100%] Built target my_safe_process
make install
ln -s /application/mysql-5.5.32/ /application/mysql
如果上述操作未出现错误,则MySQL5.5.32软件cmake方式的安装就算成功了。
########################
配置mysql配置文件
cd /home/lvnian/tools/mysql-5.5.32
cp support-files/my-small.cnf /etc/my.cnf
########################
初始化数据库
chown -R mysql.mysql /application/mysql/data
chmod -R 1777 /tmp/
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
##############
如果出现下面两个ok就是出现初始化成功了
Installing MySQL system tables...
OK
Filling help tables...
OK
出现下面警告也是正常的
WARNING: The host ‘MySQL‘ could not be looked up with resolveip.
如果你想让警告也不出现:
那就在/etc/hosts 中添加 hostname中显示的主机名
########################
启动mysql
netstat -lnt
/application/mysql/bin/mysqld_safe &
netstat -lnt
netstat -lnt |grep 3306
########################
设置传统启动方法:
/bin/cp /home/lvnian/tools/mysql-5.5.32/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld stop
netstat -lnt
/etc/init.d/mysqld start
netstat -lnt
########################
设置mysql环境变量
echo "PATH=$PATH:/application/mysql/bin/" >>/etc/profile
source /etc/profile
which mysql
########################
进入mysql
mysql
mysql简单优化
delete from mysql.user where host=‘::1‘ ;
delete from mysql.user where host=‘mysql‘ ; ##这个mysql是主机名
delete from mysql.user where host=‘localhost‘ and user=‘ ‘ ;
也可以用drop删除
show databases ;
drop database test ;
show databases ;
################################
添加额外管理员
delete from mysql.user;
grant all privileges on *.* to system@‘localhost‘ identified by ‘lvnian2009’ with grant option;
flush privileges;
#######给mysql添加密码:
在linux命令行下添加用户密码
/application/mysql/bin/mysqladmin -uroot password lvnian
在linux命令行下修改用户密码
mysqladmin -uroot -p‘lvnian‘ password ‘lvnian2009‘
##############设置mysql开机自启动
chkconfig --add mysqld
chkconfig mysqld --list
chkconfig mysqld on
chkconfig mysqld --list
本文出自 “奋斗吧” 博客,请务必保留此出处http://lvnian.blog.51cto.com/7155281/1698823
原文地址:http://lvnian.blog.51cto.com/7155281/1698823