当前位置:   article > 正文

ubuntu 编译mysql_ubuntu编译安装mysql

ubuntu mysql 编译

一、安装插件

1.apt-get install cmake

2.apt-get install bison

3.apt-get install libncurses5-dev

4.apt-get install gcc g++

二、下载安装包

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.18.tar.gz

tar zxvf mysql-boost-5.7.18.tar.gz

三、创建mysql用户组

groupadd mysql

useradd -g mysql mysql

四、编译安装mysql

cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/usr/local/mysql/data \-DWITH_BOOST=./boost/boost_1_59_0 \-DSYSCONFDIR=/etc \-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_PARTITION_STORAGE_ENGINE=1\-DWITH_FEDERATED_STORAGE_ENGINE=1\-DWITH_BLACKHOLE_STORAGE_ENGINE=1\-DWITH_MYISAM_STORAGE_ENGINE=1\-DWITH_MEMORY_STORAGE_ENGINE=1\-DENABLED_LOCAL_INFILE=1\-DWITH_READLINE=1\-DMYSQL_TCP_PORT=3306\-DEXTRA_CHARSETS=all\-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci

make

make install

五、配置mysql

1.设置mysql用户权限

chown -R mysql /usr/local/mysql

chgrp -R mysql /usr/local/mysql

2.修改配置文件

官网从5.7.18不在二进制包中提供my-default.cnf文件,如果有需要添加的话,找到my.cnf文件所在位置,新建my.cnf文件添加配置即可

找到my.cnf应该所在位置:mysql --help | grep my.cnf

vim /etc/my.conf,临时添加如下配置:

[client]port= 3306socket= /tmp/mysql.sockdefault-character-set =utf8[mysqld]

user =mysql

port= 3306socket= /tmp/mysql.sock

basedir= /usr/local/mysql

datadir= /usr/local/mysql/data

2.初始化数据库

/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

记住这个密码,更改root密码时使用

5a4151deac9801373ef8f1a5c2338320.png

3.启动mysql

/usr/local/mysql/support-files/mysql.server start

4.设置mysql root密码

mysql -h 127.0.0.1 -u root -p

上面截图里初始化时的密码:

a33b0667aa5aad5b61e3eb02627185b7.png

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/65190
推荐阅读
相关标签
  

闽ICP备14008679号