CentOS6.5 安装mysql环境

1.先安装cmake(是更先进的configure)

shell># cd /home/jinnan/tar

shell># tar zxvf cmake-2.8.5.tar.gz

shell># cd cmake-2.8.5

shell># ./bootstrap

shell># make && make install

2.编译安装MySQL

shell># cd /home/jinnan/tar

shell># tar zxvf mysql-5.5.17.tar.gz

shell># cd mysql-5.5.17

shell># cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci

(准备安装到那里

数据存储目录

默认的字符集

校对字符集)

(报错就安装ncurses-devel)

shell># mount .....挂载光盘进入到光盘的Package目录/


shell># rpm -ivh ncurses-devel-5.7-3.20090208.el6.i686.rpm

shell># rm -f CMakeCache.txt    //删除mysql文件夹下的该文件

shell># cmake 。。。 。。。            //重新cmake上面的内容

shell># make && make install

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

3.配置并初始化MySQL

shell># useradd  mysql   (该mysql用户会存在于同名的组下)

shell># chmod +x /usr/local/mysql

 

(数据库用户信息不小心删除光了,删除data目录,从此开始执行以下指令,直至结束)

shell># chown -R mysql.mysql /usr/local/mysql

 

初始化mysql数据库  

shell># /usr/local/mysql/scripts/mysql_install_db \

--user=mysql \

--basedir=/usr/local/mysql \

--datadir=/usr/local/mysql/data &

 

把mysql安装文件(除了data)的主人都改为root,避免数据库恢复为出厂设置。

shell># chown -R root /usr/local/mysql

shell># chown -R mysql /usr/local/mysql/data

 

& 后台运行mysql服务

shell># /usr/local/mysql/bin/mysqld_safe --user=mysql &

 

//查看mysql是否有启动

shell># ps –A | grep mysql   

 

测试数据库并进行安全操作

shell># /usr/local/mysql/bin/mysql –u root

mysql> show databases; 

mysql> use mysql;

mysql> select host,user,password from user;

删掉不相关的账号密码,只保留一个host为localhost的root

mysql> delete from user where user!='root';

mysql> delete from user where host!='localhost';

 

接上步,修改mysql密码(可不做此步,默认无密码),password()为mysql的md5加密,mysql登录和phpMyAdmin登录时,密码都会进行md5加密验证,没有使用password()加密写入数据库会造成无法登录。

mysql> UPDATE user SET Password=password('123456') WHERE user='root';

mysql> flush privileges;

 

退出mysql

 

mysql> exit;

4.配置开机自启动服务项

shell># cp 安装包解压目录/support-files/mysql.server  /etc/init.d/mysqld                                                

shell># chmod +x /etc/init.d/mysqld

shell># chkconfig --add mysqld

shell># chkconfig mysqld on    //设置开机自启动

 

配置文件路径:

shell># vi /etc/rc.d/rc.local

在  文件中增加启动相关服务的命令如下:

/usr/local/http2/bin/apachectl start

/usr/local/mysql/bin/mysqld_safe --user=mysql &

service vsftpd start

你可能感兴趣的:(CentOS,LAMP)