linux安装mysql 5.7.28

解压

cd /mysql
tar -zxvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql5.7
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
chown -R mysql.mysql mysql5.7/
cd mysql5.7/bin
vi /etc/my.cnf
./mysqld --initialize-insecure --user=mysql
cd ../
cp support-files/mysql.server /etc/init.d/mysql
service mysql start

/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 = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir = /mysql/mysql5.7
datadir = /mysql/mysql5.7/data
# port = .....
# server_id = .....
# socket = .....

# 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 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

进入终端,修改root密码,默认无密码

ln -s /mysql/mysql5.7/bin/mysql /usr/bin
chkconfig --add mysql
mysql -uroot -p

更新密码

alter user 'root'@'localhost' identified by 'root';
flush privileges;

开启远程连接权限

update user set host='%' where user='root';
flush privileges;

或者

grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;

其中%可以替换成指定主机ip,identified by后跟密码
附录一篇博客链接:https://blog.csdn.net/ncdx111/article/details/79818304

发布了1230 篇原创文章 · 获赞 310 · 访问量 223万+

猜你喜欢

转载自blog.csdn.net/huangbaokang/article/details/105386329