- 解压文件,移动到/usr/local/mysql3308目录下
tar -zxvf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.35-linux-glibc2.12-x86_64 /usr/local/mysql3308
- 创建数据目录
mkdir -p /data/mysql3308
- 给mysql用户赋权
chown mysql:mysql -R /data/mysql3308
chown mysql:mysql -R /usr/local/mysql3308
- 创建配置文件
vim /usr/local/mysql3308/my.cnf
--------
[mysqld]
bind-address=0.0.0.0
port=3308
user=mysql
basedir=/usr/local/mysql3308
datadir=/data/mysql3308
socket=/tmp/mysql3308.sock
log-error=/data/mysql3308/mysql.err
pid-file=/data/mysql3308/mysql.pid
#character config
character_set_server=utf8mb4
symbolic-links=0
explicit_defaults_for_timestamp=true
lower_case_table_names=1
default_storage_engine=InnoDB
sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
[client]
port=3308
socket=/tmp/mysql3308.sock
----------
chown mysql:mysql -R /usr/local/mysql3308/my.cnf
- 初始化mysql
cd /usr/local/mysql3308/bin
./mysqld --defaults-file=/usr/local/mysql3308/my.cnf --basedir=/usr/local/mysql3308/ --datadir=/data/mysql3308/ --user=mysql --initialize
- 查看mysql 初始密码
cat /data/mysql3308/mysql.err
dxbiyanGC4_w
- 修改服务文件
vim /usr/local/mysql3308/support-files/mysql.server
basedir=/usr/local/mysql3308
datadir=/data/mysql3308
conf=/usr/local/mysql3308/my.cnf
- 启动mysql
./mysqld_safe --defaults-file=/usr/local/mysql3308/my.cnf --user=mysql &
- 如果出现错误 查看错误日志
cat /data/mysql3308/localhost.localdomain.err
-
查看服务是否启动成功
ps -ef|grep mysql3308 -
连接mysql
./mysql -S /tmp/mysql3308.sock -u root -pdxbiyanGC4_w
- 修改密码 远程登录
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('2be$iU0Fl^cIF2F&');
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '2be$iU0Fl^cIF2F&' WITH GRANT OPTION; flush privileges;
FLUSH PRIVILEGES;
exit;
- 查看配置文件是否生效
show variables like 'lower_case_table_names';
show variables like "%data%";
标签:--,安装,数据库,MySQL,data,usr,mysql,local,mysql3308
From: https://www.cnblogs.com/yahah/p/17081472.html