二进制 mysql8 mysql5.7 mysql5.6

随手写的,不喜请绕过

下载

wget -c http://mirrors.dotsrc.org/mysql/Downloads/MySQL-8.0/mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz
wget -c http://mirrors.dotsrc.org/mysql/Downloads/MySQL-5.7/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
wget -c  http://mirrors.dotsrc.org/mysql/Downloads/MySQL-5.6/mysql-5.6.51-linux-glibc2.12-x86_64.tar.gz

解压

tar -xf mysql-8.0.26-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
ln -s /usr/local/mysql-8.0.26-linux-glibc2.12-x86_64 /usr/local/mysql

yum install gcc gcc-c++ openssl openssl-devel libaio libaio-devel  ncurses  ncurses-deve
yum -y install numactl

cd /usr/local/mysql
vim my.cnf
根据需求自己定义


[mysqld]
basedir = /usr/local/mysql
datadir = /data/mysql
port = 3306
server_id = 2
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

log-bin-index = master-bin.index
log-bin = mysql-bin
binlog-format = ROW
expire_logs_days = 3

max_connections = 5000
open_files_limit = 263154
sync_binlog = 500
innodb_flush_log_at_trx_commit = 2
wait_timeout = 1000
interactive_timeout = 1000
group_concat_max_len = 200000
binlog_checksum = none
character_set_server = utf8
log_error = /var/log/mysql/error.log

long_query_time=2
slow-query-log=On  
slow_query_log_file="mysql_slow_query.log"
log_queries_not_using_indexes=off 
groupadd mysql
useradd -s /sbin/nologin -r -g mysql mysql
cp -r support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
mkdir -p /data/mysql
chown -R mysql. /data/mysql
mkdir -p /var/log/mysql
chown -R mysql:mysql /var/log/mysql/

cat /etc/init.d/mysqld |cat -n|sed -n ‘46,47p’

46  basedir=/usr/local/mysql
47  datadir=/data/mysql
echo "export PATH=$PATH:/usr/local/mysql/bin"  >>  /etc/profile
source /etc/profile

初始化 - 试用mysql8 mysql5.7

[root@localhost mysql]# /usr/local/mysql/bin/mysqld  \
--initialize-insecure  \
--user=mysql  \
--datadir=/data/mysql/  \
--basedir=/usr/local/mysql/   

初始化 - 试用 mysql5.6

/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql  --basedir=/usr/local/mysql

启动

[root@c5aa8f76c740 mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS! 

改密码: - 试用 mysql5.6

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'

改密码: - 试用mysql 5.7 mysql 8

[root@localhost mysql]# /usr/local/mysql/bin/mysql  -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 84
Server version: 8.0.26 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql>  FLUSH PRIVILEGES; 

另:超级远程用户,慎用

grant all on *.* to toyix@"%" identified by "123456";
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='toyix';
flush privileges;

-----------end

你可能感兴趣的:(#,LNMP,二进制,mysql8)