赞
踩
注:我用的是阿里云服务器
mkdir mysql
进入mysql文件夹
tar zxvf mysql-5.7.43-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.43-linux-glibc2.12-x86_64/ mysql-5.7
groupadd mysql
useradd -r -g mysql songy
mkdir data
chown songy:mysql -R /opt/mysql/mysql-5.7/data/
vim /etc/my.cnf
- [mysqld]
- bind-address=0.0.0.0
- port=3306
- user=songy
- basedir=/opt/mysql/mysql-5.7
- datadir=/opt/mysql/mysql-5.7/data
- socket=/tmp/mysql.sock
- log-error=/opt/mysql/mysql-5.7/data/mysql.err
- pid-file=/opt/mysql/mysql-5.7/data/mysql.pid
- max_connections=10000
- max_user_connections=2000
- wait_timeout=200
- character_set_server=utf8mb4
- symbolic-links=0
- explicit_defaults_for_timestamp=true
- lower_case_table_names=1
注: 记得改成自己的目录
./mysqld --defaults-file=/etc/my.cnf --basedir=/opt/mysql/mysql-5.7 --datadir=/opt/mysql/mysql-5.7/data --user=songy --initialize
执行以后控制台报了如下错误:
执行如下命令,安装一下即可:
yum -y install libaio
3、再次执行刚才的命令,然后执行命令查看日志当中的初始密码
cat /opt/mysql/mysql-5.7/data/mysql.err
这是MySQL的初始登录密码
BySkmTf4Yw/X
cd /opt/mysql/mysql-5.7/support-files
sudo ./mysql.server start
启动成功
cd /opt/mysql/mysql-5.7/bin
./mysql -u root -p
注意,遇到这种错误可以显示的输入密码继续登录(这是因为在这里输入密码看不见,你可能输入错误)
加了密码,还是报错(这里需要去掉-p后面的空格)
./mysql -u root -pBySkmTf4Yw/X
登陆成功!
SET PASSWORD = PASSWORD('root');
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
FLUSH PRIVILEGES;
use mysql
update user set host = '%' where user = 'root';
FLUSH PRIVILEGES;
在阿里云控制台,防火墙配置放行端口号,否则无法访问
连接成功
ln -s /opt/mysql/mysql-5.7/support-files/mysql.server /etc/init.d/mysql
ln -s /opt/mysql/mysql-5.7/bin/mysql /usr/bin/mysql
service mysql restart
chmod +x /etc/init.d/mysql
chkconfig --add mysql
chkconfig --list
2-5级别显示为on,表示开机自动启动
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。