Linux 安装 MySQL-5.7.23

Linux 安装 MySQL-5.7.23
================================================================================================

yum -y install wget cmake gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel
yum install -y libaio libaio-devel


目录规划:
 mkdir -p /root/tools
 mkdir -p /home/mysql
 mkdir -p /usr/local/mysql

上传mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz 安装包到/root/tools

tar xf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz -C /usr/local

cd /usr/local
mv mysql-5.7.23-linux-glibc2.12-x86_64  mysql

cd mysql

groupadd mysql
useradd -r -g mysql -s /sbin/nologin mysql
mkdir -p /home/mysql
chown -R mysql.mysql /usr/local/mysql
chown -R mysql.mysql /home/mysql
chmod -R 755 /usr/local/mysql/
chmod -R 755 /home/mysql/

vi /etc/profile
export PATH=$PATH:/usr/local/mysql/bin
source /etc/profile

mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql
  --datadir=/home/mysql
mysql_ssl_rsa_setup --user=mysql --basedir=/usr/local/mysql  --datadir=/home/mysql

cp support-files/mysql.server /etc/init.d/mysqld
vi /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/home/mysql



vi /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL
SourcePath=/etc/init.d/mysqld
Before=shutdown.target

[Service]
User=mysql
Type=forking
ExecStart=/etc/init.d/mysqld start
ExecStop=/etc/init.d/mysqld stop

[Install]
WantedBy=multi-user.target


systemctl daemon-reload
systemctl enable mysqld.service
systemctl list-unit-files|grep mysqld

cat /etc/my.cnf

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
innodb_buffer_pool_size = 10G

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
log_bin
character-set-server=utf8
collation-server=utf8_bin
init-connect='SET NAMES utf8'
# These are commonly set, remove the # and set as required.
basedir = /usr/local/mysql
datadir = /home/mysql
port = 3306
server_id = 1
socket = /tmp/mysql.sock
binlog_format = statement
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
log_bin_trust_function_creators = on
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

lower_case_table_names=1


启动:
方法一:systemctl start mysqld
方法二:/etc/init.d/mysqld start


修改root密码:
mysql -u root -p
mysql> use mysql;
mysql> set password for root@localhost = password('mysql123');
mysql> flush privileges;


firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="10.1.3.0/24" port port="3306" protocol="tcp" accept'  

firewall-cmd --reload; firewall-cmd --list-all

----------------------------------------------------------------------------------------------------------------------------------

更新mysql5.7.19 root 密码:

shell>/etc/init.d/mysqld stop
shell>mysqld_safe --skip-grant-tables &
shell>mysql -u root -p                 #输入命令回车进入,出现输入密码提示直接回车。
mysql>use mysql;
mysql>update mysql.user set authentication_string = password("mysql123") where user='root';
mysql>flush privileges;          #更新权限
mysql>quit       

posted @ 2020-09-29 17:40  walkersss  阅读(420)  评论(0编辑  收藏  举报