码迷,mamicode.com
首页 > 数据库 > 详细

安装mysql

时间:2017-11-15 22:12:02      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:mysql

一:安装mysql

1.在web服务器上安装mysql:

yum -y remove mysql mysql-server  ##卸载mysql的rpm包

确认yum源指定到ftp:

[root@www ~]# cat /etc/yum.repos.d/centos.repo 

[local]

name=local

baseurl=ftp://192.168.100.100/centos6

enabled=1

gpgcheck=0


yum -y install ncurses-*

lftp 192.168.100.100  ##下载mysql和cmake

lftp 192.168.100.100:/tools> get cmake-2.8.6.tar.gz mysql-5.5.22.tar.gz 

2.解压cmake,安装基础环境

tar zxvf /root/cmake-2.8.6.tar.gz -C /usr/src/

cd /usr/src/cmake-2.8.6

3.配置,编译安装cmake

./configure &&gmake &&gmake install

4.解压mysql

tar zxvf /root/mysql-5.5.22.tar.gz -C /usr/src/

cd /usr/src/mysql-5.5.22/

5.使用cmake进行配置mysql

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql   #指定安装目录\

-DDEFAULT_CHARSET=utf8   #指定字符集为utf8 \

-DDEFAULT_COLLATION=utf8_general_ci   ##指定字符校验 \

-DWITH_EXTRA_CHARSETS=all   ##支持额外字符集\

-DSYSCONFDIR=/etc/  ##指定配置文件位置

make &&make install   #编译安装

echo $?查看上命令是否执行成功

ls  /usr/local/mysql  ##验证安装目录


二.配置mysql

1.复制配置文件

cp /usr/src/mysql-5.5.22/support-files/my-medium.cnf /etc/my.cnf

2.添加系统服务

cp /usr/src/mysql-5.5.22/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld  on

3.优化PATH路径,执行命令时方便,单引号双引号都行

echo ‘export PATH=$PATH:/usr/local/mysql/bin‘  >>/etc/profile

source /etc/profile  ##执行文件


4.初始化mysql,创建用户,赋权

userdel -r mysql  ##如果用户已经存在则删除,如果不存在不管

useradd -M -s /sbin/nologin mysql

chown -R mysql:mysql /usr/local/mysql

/usr/local/mysql/scripts/mysql_install_db  \

--basedir=/usr/local/mysql \

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

5.启动mysql,并设置为开机启动

/etc/init.d/mysqld start

chkconfig mysqld on

6.修改密码

mysqladmin -u root password ‘123123‘ 

7.登录mysql:

mysql -uroot -p123123  ##登录,也可以用-h选项指定服务器的ip地址进行远程登录

quit


本文出自 “11628205” 博客,请务必保留此出处http://11638205.blog.51cto.com/11628205/1982051

安装mysql

标签:mysql

原文地址:http://11638205.blog.51cto.com/11628205/1982051

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!