日期:2014-05-16  浏览次数:21070 次

MySQL源码方式安装

MySQL源码方式安装

Linux环境:Linux AS 4.7

1、首先使用 rpm -qa | grep mysql 查看系统是否已安装其他版本的MySQL
2、如果已安装其他版本的MySQL,使用 rpm -e 删除,应按照rpm -qa | grep mysql查询出来的相关包顺序从下往上逐个删除。
?? 注意事项:
?? (1)、如果出现包依赖,使用 --nodeps参数强制删除。
?? (2)、如果出现多个匹配,使用 --allmatches 全部删除
3、安装mysql
??? shell> groupadd mysql

??? shell> useradd -g mysql mysql

??? shell> cd /usr/local

??? shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -

??? mysql-VERSION.tar.gz 应为mysql源码包的全路径

??? shell> mv mysql-VERSION mysql
???
??? shell> cd mysql

?

??? 改为shell> cd mysql -VERSION


增加innodb支持
??? shell> ./configure --prefix=/usr/local/mysql? --with-extra-charsets=all --with-charset=utf8 --with-plugins=all

??? shell> make

??? shell> make install

??? shell> cp support-files/my-medium.cnf /etc/my.cnf


??? 修改/etc/my.cnf配置文件
??? 在[client]增加
??? default-character-set=utf8

??? [mysqld]下增加
??? lower_case_table_names=1
??? default-character-set=utf8

??? shell> bin/mysql_install_db --user=mysql

??? shell> chown -R root? .

??? shell> chown -R mysql var

??? shell> chgrp -R mysql .

???

??? 到此mysql安装完成
4、验证
??? shell> cd /usr/local/mysql
???
??? shell> bin/mysqld_safe --user=mysql & 启动mysql

??? shell> netstat -antl 查看3306端口是否使用,有使用表示mysql启动成功

??? shell> bin/mysql -u root 查看能否登录数据库
???
??? 登录成功
??? mysql> show databases;
???
??? 显示如下表示安装成功
??? mysql> show databases;
??? +--------------------+
??? | Database?????????? |
??? +--------------------+
??? | information_schema |
??? | mysql????????????? |
??? | test?????????????? |
??? +--------------------+
??? 3 rows in set (0.00 sec)

??? mysql>
??? delete from mysql.user where User=''; --删除mysql自带的匿名帐户
??? delete from mysql.user where Host='127.0.0.1';
??? delete from mysql.user where Host='localhost.localdomain';
??? update mysql.user set Host='%'; --给root用户开启远程访问

??? mysql> FLUSH PRIVILEGES;

???

???
???
???





???
???