centos mysql-5.6.34 编译安装

前端之家收集整理的这篇文章主要介绍了centos mysql-5.6.34 编译安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
centos MysqL-5.6.34 编译安装: 准备工作: yum install gcc gcc-c++ ncurses-devel perl 安装cmake: yum install cmake 或源码安装: wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz tar -xzvf cmake-2.8.10.2.tar.gz cd cmake-2.8.10.2 ./bootstrap ; make ; make install cd ~ 新增MysqL用户组: groupadd MysqL 新增MysqL用户: useradd -r -g MysqL MysqL 新建MysqL安装目录: mkdir -p /usr/local/MysqL 新建MysqL数据库数据文件目录: mkdir -p /data/MysqLdb wget http://dev.MysqL.com/get/Downloads/MysqL-5.6/MysqL-5.6.34.tar.gz tar -zxvf MysqL-5.6.34.tar.gz cd MysqL-5.6.34 从MysqL5.5起,MysqL源码安装开始使用cmake了,设置源码编译配置脚本: cmake -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DMysqL_UNIX_ADDR=/usr/local/MysqL/MysqL.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMysqL_DATADIR=/data1/MysqLdb -DMysqL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1 make -j4 make install 修改MysqL目录所有者和组: cd /usr/local/MysqL chown -R MysqL:MysqL . cd /1data/MysqLdb chown -R MysqL:MysqL . 初始化MysqL数据库: cd /usr/local/MysqL scripts/MysqL_install_db --user=MysqL --datadir=/data1/MysqLdb 复制MysqL服务启动配置文件: cp /usr/local/MysqL/support-files/my-default.cnf /etc/my.cnf vim /etc/my.cnf [client] port = 3306 socket = /var/lib/MysqL/MysqL.sock [MysqLd] user = MysqL port = 3306 socket = /var/lib/MysqL/MysqL.sock basedir = /usr/local/MysqL datadir = /data1/MysqLdb log-error = /data1/MysqLdb/MysqL_error.log pid-file = /data1/MysqLdb/MysqL.pid 复制MysqL服务启动脚本及加入PATH路径: cp support-files/MysqL.server /etc/init.d/MysqLd vim /etc/profile PATH=/usr/local/MysqL/bin:/usr/local/MysqL/lib:$PATH export PATH source /etc/profile 启动MysqL服务并加入开机自启动(可选这个步骤,以后可以自己启动的): service MysqLd start chkconfig --level 35 MysqLd on 检查MysqL服务是否启动: netstat -tulnp | grep 3306 MysqL -u root -p 修改MysqL用户root的密码: MysqLadmin -u root password '123456' 注:也可运行安全设置脚本,修改MysqL用户root的密码,同时可禁止root远程连接,移除test数据库和匿名用户: /usr/local/MysqL/bin/MysqL_secure_installation ------------------------------------------------------------------- MysqL问题解决:-bash:MysqL:command not found 因为MysqL命令的路径在/usr/local/MysqL/bin下面,所以你直接使用MysqL命令时,系统在/usr/bin下面查此命令,所以找不到了 解决办法是: ln -s /usr/local/MysqL/bin/MysqL /usr/bin 做个链接即可 ERROR 2002 (HY000): Can't connect to local MysqL server through socket '/usr/local/MysqL/MysqL.sock' (2) 1、先查看 /etc/rc.d/init.d/MysqLd status 看看MysqL服务是否已经启动. 另外看看是不是权限问题. $service MysqLd start 或 $service MysqL start --我开始遇到的就是因为服务没启动,因为第一次玩MysqL不是很熟悉,呵呵。 2、确定你的MysqL.sock是不是在那个位置, MysqL -u 你的MysqL用户名 -p -S /var/lib/MysqL/MysqL.sock 如果错啦,就修改/etc/my.cnf: [client] socket = /var/lib/MysqL/MysqL.sock [MysqLd] socket = /var/lib/MysqL/MysqL.sock 3、如果是权限问题,则先改变权限 #chown -R MysqL:MysqL /var/lib/MysqL [root@localhost ~]# /etc/init.d/MysqLd start 启动 MysqL: [ 确定 ] [root@localhost ~]# MysqL -uroot -p ERROR 2002 (HY000): Can't connect to local MysqL server through socket '/var/lib/MysqL/MysqL.sock' (2) 原因是,/var/lib/MysqL 的访问权限问题。 shell> chown -R MysqL:MysqL /var/lib/MysqL 接着启动服务器 shell> /etc/init.d/MysqL start 服务器正常启动后察看 /var/lib/MysqL 自动生成MysqL.sock文件。 4、修改/etc/my.conf: [MysqLd] datadir=/usr/local/MysqL/data socket=/var/lib/MysqL/MysqL.sock [MysqL.server] user=MysqL basedir=/usr/local/MysqL If there is not currently a section called [client],add one at the bottom of the file and copy the socket= line under the [MysqLd] section such as: [client] socket=/var/lib/MysqL/MysqL.sock 如果发现问题依旧,尝试运行/etc/init.d/MysqL start报错:Starting MysqLCouldn't find MysqL manager or server 如是MysqLd服务没启,运行/usr/local/MysqL/bin/MysqLd_safe & 原文链接:https://www.f2er.com/centos/379818.html

猜你在找的CentOS相关文章