mysql 5.1.73官方下载地址
http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz
md5:887f869bcc757957067b9198f707f32f
随便下载到什么地方
然后执行下面 的
mkdir -p /db/mysql
mkdir -p /usr/local/mysql
mkdir -p /usr/local/mysql/var
mkdir -p /usr/local/mysql/data && mkdir -p /usr/local/mysql/run && mkdir -p /usr/local/mysql/log && mkdir -p /usr/local/mysql/var
useradd -s /sbin/nologin mysql
chown -R mysql.mysql /db/mysql/
chown -R mysql.mysql /usr/local/mysql/
yum install -y gcc yum install -y gcc-c++ yum -y install ncurses* yum install -y libtermcap*
./configure --enable-thread-safe-client --enable-assembler --with-server-suffix =" for >>>MySQL Database of Zebra by Yhc<<<" --without-debug --with-extra-charsets=complex --prefix=/usr/local/mysql
make -j 12 && make install 这里的-j 12 没看懂啥子意思
#添加PATH
echo "PATH=\"/usr/local/mysql/bin:\$PATH\"" >> /etc/profile && export PATH="/usr/local/mysql/bin:$PATH"
#strip可执行文件
strip /usr/local/mysql/libexec/mysqld
#添加LIB PATH
echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf && ldconfig
#将my.cnf文件cp到/etc目录下
/bin/cp -r /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf && chown mysql:mysql /etc/my.cnf
sed -i 's/skip-federated/#skip-federated/' /etc/my.cnf
cd /usr/local/mysql/bin
ln -s ./mysql ./test_mysql
ln -s ./mysqladmin ./adminmysql
ln -s ./mysql_install_db ./install_db_mysql
ln -s ./mysqld_safe ./safe_mysqld
#初始化Mysql表
cd /usr/local/mysql/bin
./install_db_mysql --user=mysql 或者 ./mysql_install_db --user=mysql --datadir=/db/mysql/
若是多实例的话要分别初始化,如果你只是默认的一个实例,下面的三个就不用执行了
./mysql_install_db --user=mysql --datadir=/db/mysql/data1 --defaults-file=/etc/my.cnf
./mysql_install_db --user=mysql --datadir=/db/mysql/data2 --defaults-file=/etc/my.cnf
./mysql_install_db --user=mysql --datadir=/db/mysql/data3 --defaults-file=/etc/my.cnf
启动多实例
启动全部实例:/usr/local/mysql/bin/mysqld_multi start
查看全部实例状态:/usr/local/mysql/bin/mysqld_multi report
我们仅仅启动单个实例:/usr/local/mysql/bin/mysqld_multi start 3306
停止单个实例:/usr/local/mysql/bin/mysqld_multi stop 3306
查看单个实例状态:/usr/local/mysql/bin/mysqld_multi report 3306
# 单个实例启动或关闭
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 1
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 2
# 双实例同时启动或关闭
# mysqld_multi --defaults-file=/etc/my.cnf start/stop 1,2
# 查看MySQL是否启动,,这个不一定好用,先不管
# mysqld_multi --defaults-file=./my.cnf report 1,2
mysql -S /tmp/mysql11.sock 进入第一个库 这个也先不管
mysql -S /tmp/mysql22.sock 进入第二个库 这个也先不管
把下面的执行了
cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chown -R root /usr/local/mysql && chown -R mysql /usr/local/mysql/var && chgrp -R mysql /usr/local/mysql
然后启动mysql
service mysqld start
然后登陆命令行的mysql
mysql -u root -p 回车密码为空
然后执行下面的SQL
use mysql;
update user set host = '%' where user = 'root' and host = 'localhost';
exit;
记得分号
然后
service mysqld stop
service mysqld start
然后这个时候你可以再地球上的其他地方远程访问你的mysql服务器了.记住哦,密码为空哦
如果喜欢我的教程请多多支持麻将币哦