mysql 5.5源码包下载方式
https://download.csdn.net/download/weixin_44578029/13765465
也可以私信我找我下载
mysql-5.5.46.tar.gz
脚本内容:
#!/bin/sh # 参数设置 INSTALL_PATH=/usr/local/mysql # 指定安装目录 DATA_PATH=/mnt/datadisk1/mysql # 指定数据目录 if [ -s /etc/my.cnf ];then rm -rf /etc/my.cnf fi echo "----------------------------------start install mysql -----------------------------" yum install -y gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cmake mkdir -p $DATA_PATH if [ 'grep "mysql" /etc/passwd | wc -l' ]; then echo "adding user mysql" groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql else echo "mysql user exists" fi echo "------------------------------unpackaging mysql -----------------------------------" tar -xvf mysql-5.5.46.tar.gz cd mysql-5.5.46 echo "-------------------------configuring mysql,please wait-----------------" cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MEMORY_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=$DATA_PATH \ -DMYSQL_USER=mysql if [ $? -ne 0 ];then echo "configure failed ,please check it out!" exit 1 fi echo "make mysql, please wait for 10 minutes" make if [ $? -ne 0 ];then echo "make failed ,please check it out!" exit 1 fi make install chmod +w $INSTALL_PATH chown -R mysql:mysql $INSTALL_PATH ln -s $INSTALL_PATH/lib/libmysqlclient.so.16 /usr/lib/libmysqlclient.so.16 cd support-files/ cp my-large.cnf /etc/my.cnf cp mysql.server /etc/init.d/mysqld sed -i 's#^thread_concurrency = 8#& \ndatadir = '$DATA_PATH' \nbasedir = '$INSTALL_PATH' \nlog-error = '$INSTALL_PATH'/mysql_error.log \npid-file = '$INSTALL_PATH'/data/mysql.pid \ndefault-storage-engine=MyISAM \nuser = mysql#g' /etc/my.cnf $INSTALL_PATH/scripts/mysql_install_db --user=mysql --basedir=$INSTALL_PATH --datadir=$DATA_PATH chmod +x /etc/init.d/mysqld sed -i "s#^basedir=#basedir="$INSTALL_PATH"#g" /etc/init.d/mysqld sed -i "s#^datadir=#datadir="$DATA_PATH"#g" /etc/init.d/mysqld chkconfig --add mysqld chkconfig --level 345 mysqld on export PATH=/usr/local/mysql/bin:$PATH ln -s $INSTALL_PATH/bin/mysql /usr/bin echo "------------------------------------------------------------------------------------------" echo "------------------------mysql install successful,congratulations!-------------------------" echo "------------------------------------------------------------------------------------------"
脚本最后执行完会有显示 登录方式
找不到了可以直接
mysql -uroot -h 自己的主机名或ip地址 不可以 是127 -pnew_password
如果想去掉-h 改吧my.cnf里面的两个socke去掉,然后重启mysql