美文网首页
源码安装mysql5.7.30,端口号3307

源码安装mysql5.7.30,端口号3307

作者: 草帽路飞S | 来源:发表于2020-10-26 18:17 被阅读0次

    本地服务器已有mysql5.7.19,端口号3306

    新增一个mysql5.7.30 端口号为3307

    因目录不可相同,需修改,则用源码安装

    mysql源码下载地址:https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30.tar.gz

    mysql-boost下载地址:https://downloads.mysql.com/archives/get/p/23/file/mysql-boost-5.7.30.tar.gz

    源码安装需要boost,解压下载的tar.gz,然后把boost目录拷贝至mysql目录下或者自定义,cmake时添加参数:-DWITH_BOOST=/xxx/xxx/boost/

    参考:https://blog.csdn.net/u012767761/article/details/78185768/

    1、创建3307编译目录

    mkdir -p /home/mysql3307/data

    mkdir -p /home/mysql3307/log

    chown -R mysql.mysql /home/mysql3307

    chmod 750 /home/mysql3307

    2、源码编译

    tar -zxvf mysql-5.7.30.tar.gz

    cd mysql-5.7.30

    cmake . -DCMAKE_INSTALL_PREFIX=/home/mysql3307-DMYSQL_UNIX_ADDR=/home/mysql3307/mysql3307.sock-DDEFAULT_CHARSET=utf8mb4-DDEFAULT_COLLATION=utf8mb4_general_ci-DMYSQL_DATADIR=/home/mysql3307/data-DMYSQL_TCP_PORT=3307-DWITH_BOOST=/home/mysql3307/boost-DMYSQL_USER=mysql

    make

    make install

    3、初始化数据库

    cp support-files/my-medium.cnf /home/mysql3307/my.cnf

    vi /home/mysql3307/my.cnf

    配置文件内容:

    [mysqld]

    federated

    character-set-server=utf8mb4

    datadir=/home/mysql3307/data

    socket=/home/mysql3307/mysql3307.sock

    [mysqld_safe]

    log-error=/home/mysql3307/log/mysqld3307.log

    pid-file=/home/mysql3307/mysqld3307.pid

    [mysql]

    default-character-set=utf8mb4

    [client]

    default-character-set=utf8mb4

    注意修改基础路径和数据路径,不要与3306冲突。

    不需要密码,用加粗标红参数:

    ./mysqld--initialize-insecure--user=mysql --basedir=/home/mysql3307--datadir=/home/mysql3307/data

    4、编辑mysql3307.server

    cp support-files/mysql.server /etc/init.d/mysql3307.server

    vi /etc/init.d/mysql3307.server

    修改:

    basedir=/home/mysql3307 #46行

    datadir=/home/mysql3307/data #47行

    mysqld_pid_file_path=/home/mysql3307/mysqld3307.pid #63行

    conf=/home/mysql3307/my.cnf #207行

    5、启动、停止:

    启动(记得加&,启动脚本正在优化):

    /home/mysql3307/bin/mysqld_safe --datadir=/home/mysql3307/data --socket=/home/mysql3307/mysql3307.sock --pid-file=/home/mysql3307/mysqld3307.pid --log-error=/home/mysql3307/log/mysqld3307.log --basedir=/home/mysql3307 --user=mysql --port=3307 &

    停止:

    service mysql3307.server stop

    6、登录mysql3307(初始化后没有密码):

    mysql -uroot -p --port=3307 --socket=/home/mysql3307/mysql3307.sock

    7、修改密码,给予权限:

    set password = password('123456');

    (重新登录)

    grant all privileges on *.* to 'root' @'%' identified by '123456';

    flush privileges;

    8、查看字符集,引擎

    show variables like 'character_set_%';

    show engines;

    相关文章

      网友评论

          本文标题:源码安装mysql5.7.30,端口号3307

          本文链接:https://www.haomeiwen.com/subject/tsczmktx.html