Mysql安装--【2】

环境:

linux

CentOS6.8

epel

http://mirrors.aliyun.com/repo/Centos-6.repo

mysql

mysql-5.5.49.tar.gz

kernel

2.6.32-642.el6.x86_64

本机IP

10.0.0.51

1、安装依赖包

[root@db01 tools]# yum -y install cmake ncurses-devel

2、上传源码包

[root@db01 ~]# mkdir -p /application/[root@db01 ~]# mkdir -p /server/tools[root@db01 ~]# cd /server/tools[root@db01 tools]# rz[root@db01 tools]# tar xf mysql-5.5.49.tar.gz [root@db01 tools]# cd mysql-5.5.49

3、编译安装

cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.49 \-DMYSQL_DATADIR=/application/mysql-5.5.49/data \-DMYSQL_UNIX_ADDR=/application/mysql-5.5.49/tmp/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \-DENABLED_LOCAL_INFILE=ON \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_FEDERATED_STORAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \-DWITH_FAST_MUTEXES=1 \-DWITH_ZLIB=bundled \-DENABLED_LOCAL_INFILE=1 \-DWITH_READLINE=1 \-DWITH_EMBEDDED_SERVER=1 \-DWITH_DEBUG=0

 

提示,编译时可配置的选项很多,具体可参考官方文档:

make

#[100%] Built target my_safe_process

make install

4、软连接

ln -s /application/mysql-5.5.49/ /application/mysql

如果上述操作未出现错误,则MySQL5.5.49软件cmake方式的安装就算成功了

检查:

[root@db01 mysql-5.5.49]# ln -s /application/mysql-5.5.49//application/mysql[root@db01 mysql-5.5.49]# ll /application/total 4lrwxrwxrwx  1root root   26 Nov 11 18:25 mysql ->/application/mysql-5.5.49/drwxr-xr-x 13 root root 4096 Nov 11 18:25mysql-5.5.49

5、初始化

[root@db01 ~]# /application/mysql/scripts/mysql_install_db--basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysqlInstalling MySQL system tables...161111 18:35:25 [Note] /application/mysql//bin/mysqld(mysqld 5.5.49) starting as process 14060 ...OKFilling help tables...161111 18:35:25 [Note]/application/mysql//bin/mysqld (mysqld 5.5.49) starting as process 14067 ...OK To start mysqld at boot time you have to copysupport-files/mysql.server to the right place foryour system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQLroot USER !To do so, start the server, then issue thefollowing commands: /application/mysql//bin/mysqladmin -u root password'new-password'/application/mysql//bin/mysqladmin -u root -h db01password 'new-password' Alternatively you can run:/application/mysql//bin/mysql_secure_installation which will also give you the option of removing thetestdatabases and anonymous user created bydefault.  This isstrongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with:cd /application/mysql/ ;/application/mysql//bin/mysqld_safe & You can test the MySQL daemon withmysql-test-run.plcd /application/mysql//mysql-test ; perlmysql-test-run.pl Please report any problems athttp://bugs.mysql.com/

6、复制配置文件到etc目录下

[root@db01 ~]# /bin/cp /application/mysql/support-files/my-small.cnf /etc/my.cnf

7、创建mysql用户并设置目录权限

[root@db01 ~]# useradd -s /sbin/nologin mysql -M[root@db01 ~]# chown -R mysql.mysql /application/mysql/[root@db01 ~]# ls -l /application/mysql/

  8、添加/etc/init.d/mysql文件

[root@db01 ~]# /bin/cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld

9、替换/etc/init.d/mysqld内的路径信息

[root@db01 ~]# sed -i's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

10、启动mysql

[root@db01 ~]# /etc/init.d/mysqld startStarting MySQL.. SUCCESS![root@db01 ~]# ss -lntup|grep mysqltcp   LISTEN     0      50                     *:3306                  *:*      users:(("mysqld",14328,10))
[root@db01 ~]# chkconfig mysqld on[root@db01 ~]# chkconfig --list mysqldmysqld         0:off   1:off   2:on    3:on    4:on    5:on    6:off

注意!!

如何启动报错

[root@db01 mysql-5.5.49]# /etc/init.d/mysqld startStarting MySQL.. ERROR! The server quit withoutupdating PID file (/var/lib/mysql/db01.pid).

mysql在启动时没有指定配置文件时会使用/etc/my.cnf配置文件,请打开/etc/my.cnf文件查看在[mysqld]模块下有没有指定数据目录(datadir)

注意查看/etc/my.cnf文件的目录路径是否正确

解决方法:请在[mysqld]模块下设置这一行:datadir= /application/mysql/data

11、加入环境变量和开机自启动

[root@db01 ~]#PATH="$PATH:/application/mysql/bin"[root@db01 ~]# echo'PATH="$PATH:/application/mysql/bin"' >>/etc/profile[root@db01 ~]# . /etc/profile


本文出自 “宋某人c” 博客,请务必保留此出处http://syaving.blog.51cto.com/5614476/1878661

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值