前言
记录下Linux 下mysql 的安装,参照大佬 蛇皮皮蛋 - Linux安装MySQL5.7 博客实现,添加了一些自己安装中的小细节。
环境
Centos7.6 + Mysql5.7.26
安装步骤

tar -xzvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.7.26-linux-glibc2.12-x86_64 ../mysql

groupadd mysql

useradd -r -g mysql mysql

mkdir /data/mysql
chown mysql:mysql -R /data/mysql #赋予权限

vim /etc/my.cnf
[mysqld]
bind-address=0.0.0.0
port=3306
user=mysql
basedir=/usr/local/mysql
datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/mysql.err
pid-file=/data/mysql/mysql.pid
#character config
character_set_server=utf8
#symbolic-links=0
#explicit_defaults_for_timestamp=true

yum install -y libaio

cd mysql/bin/

./mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql/ --datadir=/data/mysql/ --user=mysql --initialize

cat /data/mysql/mysql.err

- 将
mysql.server 放到/etc/init.d/mysql 中
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

service mysql start

- 连接
mysql (bin 目录下,密码是mysql.err 中的那个)
./mysql -u root -p

SET PASSWORD = PASSWORD('xxx');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;

use mysql #访问mysql库
update user set host = '%' where user = 'root'; #使root能在任何host访问
FLUSH PRIVILEGES; #刷新



- End -
﹀
﹀
﹀
白嫖有风险
点赞加收藏
|