标签:mkdir exp schema 内容 cat efault more flush private
/home/chuqq/xxx/mysql/mysql-5.7.23
是mysql的源码路径,一下所有的目录都是在这个目录下进行的,如需安装,请根据自身的目录情况进行更改。
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.23.tar.gz
tar zxvf mysql-boost-5.7.23.tar.gz
cd mysql-5.7.23
mkdir -p data/mysql/installdir
mkdir -p data/mysql/datadir/3306/data
mkdir -p data/mysql/logdir/3306/{bin_log,general_log,error_log,query_log}
chuqq@chuqq-hp:~/xxx/mysql/mysql-5.7.23$ pwd
/home/chuqq/xxx/mysql/mysql-5.7.23
cmake . -DCMAKE_INSTALL_PREFIX=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/installdir -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DCOMPILATION_COMMENT=‘MySQL xxx‘ -DWITH_READLINE=ON -DWITH_BOOST=./boost -DSYSCONFDIR=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/datadir/3306/data -DMYSQL_UNIX_ADDR=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/datadir/3306/data/mysql.sock
cmake编译参数说明:https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html
出现错误CMake Error: Curses library not found. Please install appropriate package
sudo apt install libncurses5-dev
再重新执行上边的cmake指令。
编译安装,耗时1h
make -j4
make install
为方便期间,我们在源码目录创建conf文件夹放置config文件。
mkdir conf
cd conf
pwd
/home/chuqq/xxx/mysql/mysql-5.7.23/conf
vi my.cnf
my.cnf中内容如下:
[client]
port=3306
socket=data/mysql/datadir/3306/data/mysql.sock
[mysqld]
port=3306
user=mysql
socket=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/datadir/3306/data/mysql.sock
pid-file=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/datadir/3306/data/mysql.pid
basedir=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/installdir
datadir=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/datadir/3306/data
tmpdir=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/tmpdir
log_error=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/logdir/3306/error_log/mysql3.err
server-id = 1
log_bin = /home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/logdir/3306/bin_log/binlog
general_log_file=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/logdir/3306/general_log
general_log = 1
slow_query_log = ON
long_query_time = 2
slow_query_log_file = /home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/logdir/3306/query_log
log_queries_not_using_indexes = ON
进入mysql指定的install的文件夹中。
cd /home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/installdir/bin
./mysqld --initialize --user=chuqq --basedir=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/installdir --datadir=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/datadir/3306/data
输出内容:注意最后一行为随机分配的初始密码
2018-08-25T01:25:49.587444Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-08-25T01:25:50.525154Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-08-25T01:25:50.799908Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-08-25T01:25:50.993678Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: cd72821b-a805-11e8-b6a4-f0921cec4839.
2018-08-25T01:25:51.040174Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2018-08-25T01:25:51.040952Z 1 [Note] A temporary password is generated for root@localhost: liFR>7H&F%De
./mysql_ssl_rsa_setup --datadir=/home/chuqq/xxx/mysql/mysql-5.7.23/data/mysql/datadir/3306/data
输出内容:
Generating a 2048 bit RSA private key
...........................................................+++
..........................................................................................................................+++
writing new private key to ‘ca-key.pem‘
-----
Generating a 2048 bit RSA private key
.........+++
...........................................................................................................+++
writing new private key to ‘server-key.pem‘
-----
Generating a 2048 bit RSA private key
...........................................................................+++
....................................................................+++
writing new private key to ‘client-key.pem‘
-----
./mysqld_safe --defaults-file=/home/chuqq/xxx/mysql/mysql-5.7.23/conf/my.cnf &
./mysql -uroot -p
填入上步骤打印的密钥,即可登录。
SET PASSWORD = PASSWORD(‘root‘);
ALTER USER root@localhost PASSWORD EXPIRE NEVER;
flush privileges;
注意,上边设置的root用户只能在本地登录,因为设置了localhost。下边我们创建一个可以远程登录的用户。
CREATE USER ‘imax‘@‘%‘ IDENTIFIED BY ‘imax‘;
GRANT ALL ON imax.* TO ‘imax‘@‘%‘;
flush privileges;
标签:mkdir exp schema 内容 cat efault more flush private
原文地址:https://www.cnblogs.com/xxxuwentao/p/9533389.html