lnmp之mysql5.5.17安装

时间:2021-12-11 05:58:25

先执行命令yum install cmake

mysql5.5采用的是cmake安装(更先进的configure)

wget下载目录(到清华大学的镜像站下载)

[root@localhost local]# cd /usr/local/src

解压 [root@localhost src]# tar vfxz mysql-5.5.17.tar.gz

[root@localhost src]# cd /usr/local/src/mysql-5.5.17

为了防止因为缺少什么而出现错误,现在集成安装一下

[root@localhost src]# yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN pcre-devel

然后执行如下命令:

[root@localhost mysql-5.5.17]# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci

ok,cmake编译成功

再执行make && make install

时间稍长(15分钟),耐心等待中...

配置mysql文件

先查看一下:

lnmp之mysql5.5.17安装

[root@localhost mysql-5.5.17]# cp support-files/my-medium.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[root@localhost mysql-5.5.17]# useradd mysql

lnmp之mysql5.5.17安装

[root@localhost mysql-5.5.17]# chmod +x /usr/local/mysql

[root@localhost mysql-5.5.17]# chown -R mysql.mysql /usr/local/mysql

初始化mysql数据库

[root@localhost mysql-5.5.17]# /usr/local/mysql/scripts/mysql_install_db \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data &

lnmp之mysql5.5.17安装

把mysql目录的主人由mysql改为root

[root@localhost local]# chown -R root /usr/local/mysql

lnmp之mysql5.5.17安装

把mysql目录的主人由root改为mysql

[root@localhost local]# chown -R mysql /usr/local/mysql/data

lnmp之mysql5.5.17安装

运行mysql服务

[root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql &

crtl+c退出

lnmp之mysql5.5.17安装

查看是否启动成功

lnmp之mysql5.5.17安装

启动成功啦,嘿嘿

测试一把mysql

[root@localhost bin]# /usr/local/mysql/bin/mysql

lnmp之mysql5.5.17安装

设置mysql登录用户名和密码

首先,删除匿名用户:

lnmp之mysql5.5.17安装

lnmp之mysql5.5.17安装

lnmp之mysql5.5.17安装

lnmp之mysql5.5.17安装

lnmp之mysql5.5.17安装

lnmp之mysql5.5.17安装

好了,留下了 一个root的用户,就ok了

然后更改root账户的密码

lnmp之mysql5.5.17安装

还有最后一步,刷新权限,以便于立马生效

lnmp之mysql5.5.17安装

来,测试一把是否生效

lnmp之mysql5.5.17安装

lnmp之mysql5.5.17安装

ok,成功了!

如果关闭虚拟机后重新启动,首先需要运行一下这个

[root@localhost ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql &
lnmp之mysql5.5.17安装

。。。。。。。。。。。。。。。。

GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.112' IDENTIFIED BY '123456' WITH GRANT OPTION;