编译安装mysql8.0

编译安装mysql8.0

   张吉吉     2019年9月3日 01:08     1590    

1、解压开

tar -zxvf mysql-8.0.13.tar.gz

 

2、开始编译

cmake \

-DCMAKE_INSTALL_PREFIX=/usr/local/shopnc/mysql \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DENABLED_LOCAL_INFILE=ON \

-DWITH_INNODB_MEMCACHED=ON \

-DWITH_SSL=system \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \

-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \

-DDOWNLOAD_BOOST=1 \

-DWITH_BOOST=/tmp \

-DMYSQL_UNIX_ADDR=/usr/local/shopnc/mysql/data/mysql.sock \

-DSYSCONFDIR=/usr/local/shopnc/mysql/data/

 

3、开始安装

make –j 4

make install

 

4、创建用户

groupadd mysql

useradd -r -g mysql -s /bin/false mysql

 

5、编写配置文件

[client]

port = 3306

socket = /usr/local/shopnc/mysql/data/mysql.sock

[mysqld]

port = 3306

user = mysql

socket = /usr/local/shopnc/mysql/data/mysql.sock

mysqlx-socket = /usr/local/shopnc/mysql/data/mysqlx.sock

pid-file = /usr/local/shopnc/mysql/data/mysql.pid

basedir = /usr/local/shopnc/mysql

datadir = /usr/local/shopnc/mysql/data

log-error = /usr/local/shopnc/mysql/logs/mysql-error.log

tmpdir = /tmp

character-set-server = utf8

default-storage-engine = InnoDB

 

6、创建日志文件位置

mkdir /usr/local/shopnc/mysql/logs

touch /usr/local/shopnc/mysql/logs/mysql-error.log

cd /usr/local/shopnc/mysql

chown –R mysql:mysql logs/

如果这个不创建的话,肯定会有报错,如果权限不争取的话,也会有报错。

 

7、为命令创建软连接

ln -sf /usr/local/shopnc/mysql/bin/mysql /usr/sbin

ln -sf /usr/local/shopnc/mysql/bin/mysqld /usr/sbin

ln -sf /usr/local/shopnc/mysql/bin/mysqladmin /usr/sbin

 

8、初始化表

mysqld -I --user=mysql --datadir=/usr/local/shopnc/mysql/data

初始完脚本以后会有一个密码这个是必须要记住的

 

9、复制mysql的启动脚本

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

 

10、启动mysql

service mysql start

 

11、修改mysql登录密码

mysqladmin -u root -piZs2DurVfM-j password 123456

其中密码在初始化脚本的时候会得到。


文章评论

0

其他文章