> 数据库 > MySQL >

centos6.5二进制安装mysql

[root@rsync ~]# yum install libaio-devel -y    #安装共享库

[root@rsync ~]# wget http://mirrors.sohu.com/mysql/My ... ux2.6-x86_64.tar.gz #下载MySQL二进制包

[root@rsync ~]# tar xf mysql-5.5.48-linux2.6-x86_64.tar.gz #解压二进制包

[root@rsync ~]# mv mysql-5.5.48-linux2.6-x86_64 /usr/local/mysql #将二进制包移动到安装目录

[root@rsync ~]# useradd mysql -s /sbin/nologin -M #新建MySQL用户  

[root@rsync ~]# chown -R mysql.mysql /usr/local/mysql/data/ #授权MySQL用户属主

 

初始化MySQL
[root@rsync ~]# cd /usr/local/mysql
[root@rsync mysql]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/

[root@rsync mysql]# \cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf #拷贝MySQL配置文件
[root@rsync mysql]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld #拷贝MySQL启动文件  
[root@rsync mysql]# /etc/init.d/mysqld start #启动MySQL
[root@rsync mysql]# chkconfig mysqld on #设置开机启动

[root@rsync mysql]# vi /etc/profile.d/mysql.sh #设置mysql环境变量。添加如下内容

export PATH=$PATH:/usr/local/mysql/bin

[root@rsync mysql]# source /etc/profile.d/mysql.sh #执行命令使用其生效

[root@rsync mysql]# /usr/lcoal/mysql/bin/mysql_secure_installation #安全配置向导

 

[root@rsync mysql]# netstat -lntup|grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1545/mysqld         
[root@rsync mysql]# mysql -uroot -p #登录MySQL
 

 

点击下面的复制代码,粘贴至命令行执行即可。

  1. yum install libaio-devel wget -y

  2. wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.48-linux2.6-x86_64.tar.gz 

  3. tar xf mysql-5.5.48-linux2.6-x86_64.tar.gz

  4. mv mysql-5.5.48-linux2.6-x86_64 /usr/local/mysql

  5. useradd mysql -s /sbin/nologin -M

  6. chown -R mysql.mysql /usr/local/mysql/data/

  7. cd /usr/local/mysql

  8. ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/

  9. \cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf

  10. cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

  11. cp -a /usr/local/mysql/bin/* /usr/local/sbin/

  12. chmod +x /etc/init.d/mysqld

  13. /etc/init.d/mysqld start

  14. chkconfig mysqld on

  15. mysqladmin -uroot password "AbC123456"

  16. mysql -uroot -p"AbC123456"



(责任编辑:IT)