Mysql5.5编译安装

查看系统环境:

cat /etc/redhat-release


uname -r    uname -m 


注意:不要使用yum的删除功能删除软件,会删除相关依赖,导致意外问题。



 yum install gcc gcc-c++ -y


安装mysql 5.5


tar xf cmake-2.8.8.tar.gz


./configure

gmake  

gmake install


yum install ncurses-devel -y


tar xf mysql-5.5.32.tar.gz


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


ln -s /application/mysql-5.5.32/  /application/mysql


#useradd mysql -s /sbin/nologin -M -g mysql


2、配置文件

/bin/cp mysql-5.5.32/support-files/my-smail.cnf /etc/my.cnf


3、配置环境变量

export PATH=/application/mysql/bin:$PATH >>/etc/profile

tail -l /etc/profile

source /etc/profile

echo $PATH


环境变量出错解决:http://oldboy.blog.51cto.com/2561410/1122867  

ls错误:PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin


4、初始化数据文件(容易出错的步骤)


建立mysql数据文件目录


chown -R mysql.mysql /application/mysql


授权mysql用户访问mysql的安装目录


chmod -R 1777 /tmp


初始化数据库

cd /application/mysql/scripts/

chmod +x mysql_install_db

./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql



grep 'mysql.server' -r /etc/

/bin/cp support-files/mysql.server /etc/init.d/mysqld


chmod +x /etc/init.d/mysqld


/etc/init.d/mysqld start



出现Access 错误


pkill mysqld


lsof -i :3306


rm -fr /application/mysql/data/*


./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql



简单优化(安全木桶原则,最低点做起):


select user,host,password from mysql.user;


delete from mysql.user where user='';


select user,host,password from mysql.user;


delete from mysql.user where host='www';


delete from mysql.user where host=';;1';


drop databases test;



delete from mysql.user where host!='localhost' or host!='127.0.0.1';


或者干脆全部删除,添加额外管理员


delete from mysql.user;


grant all privileges on *.* to system@'localhost' identified by 'wyy' with grant option; 


with grant option 可以授权用户


flush privileges;




增加密码


/application/mysql//bin/mysqladmin -u root password 'wyy123'


字符集

/etc/sysconfig/il8n


#LANG="zh_CN.GBI8030"

LANG="zh_CN.UTF-8"



你可能感兴趣的:(mysql安装,mysql5.5,编译安装mysql)